Avoid unnecessary transition setup in reader if not transitioning
This commit is contained in:
parent
271253fd0b
commit
408c7b2ca6
2 changed files with 19 additions and 10 deletions
|
@ -891,15 +891,20 @@ class MangaController :
|
||||||
|
|
||||||
private fun openChapter(chapter: Chapter, sharedElement: View? = null) {
|
private fun openChapter(chapter: Chapter, sharedElement: View? = null) {
|
||||||
val activity = activity ?: return
|
val activity = activity ?: return
|
||||||
val intent = ReaderActivity.newIntent(activity, presenter.manga, chapter)
|
|
||||||
activity.apply {
|
activity.apply {
|
||||||
|
val intent = ReaderActivity.newIntent(activity, presenter.manga, chapter)
|
||||||
if (sharedElement != null && Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
|
if (sharedElement != null && Build.VERSION.SDK_INT != Build.VERSION_CODES.O) {
|
||||||
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
val activityOptions = ActivityOptions.makeSceneTransitionAnimation(
|
||||||
activity,
|
activity,
|
||||||
sharedElement,
|
sharedElement,
|
||||||
ReaderActivity.SHARED_ELEMENT_NAME
|
ReaderActivity.SHARED_ELEMENT_NAME
|
||||||
)
|
)
|
||||||
startActivity(intent, activityOptions.toBundle())
|
startActivity(
|
||||||
|
intent.apply {
|
||||||
|
putExtra(ReaderActivity.EXTRA_IS_TRANSITION, true)
|
||||||
|
},
|
||||||
|
activityOptions.toBundle(),
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ import com.google.android.material.slider.Slider
|
||||||
import com.google.android.material.transition.platform.MaterialContainerTransform
|
import com.google.android.material.transition.platform.MaterialContainerTransform
|
||||||
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
|
import com.google.android.material.transition.platform.MaterialContainerTransformSharedElementCallback
|
||||||
import dev.chrisbanes.insetter.applyInsetter
|
import dev.chrisbanes.insetter.applyInsetter
|
||||||
|
import eu.kanade.tachiyomi.BuildConfig
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.database.models.Chapter
|
import eu.kanade.tachiyomi.data.database.models.Chapter
|
||||||
import eu.kanade.tachiyomi.data.database.models.Manga
|
import eu.kanade.tachiyomi.data.database.models.Manga
|
||||||
|
@ -110,6 +111,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
private const val ENABLED_BUTTON_IMAGE_ALPHA = 255
|
private const val ENABLED_BUTTON_IMAGE_ALPHA = 255
|
||||||
private const val DISABLED_BUTTON_IMAGE_ALPHA = 64
|
private const val DISABLED_BUTTON_IMAGE_ALPHA = 64
|
||||||
|
|
||||||
|
const val EXTRA_IS_TRANSITION = "${BuildConfig.APPLICATION_ID}.READER_IS_TRANSITION"
|
||||||
const val SHARED_ELEMENT_NAME = "reader_shared_element_root"
|
const val SHARED_ELEMENT_NAME = "reader_shared_element_root"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -158,6 +160,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
applyAppTheme(preferences)
|
applyAppTheme(preferences)
|
||||||
|
|
||||||
// Setup shared element transitions
|
// Setup shared element transitions
|
||||||
|
if (intent.extras?.getBoolean(EXTRA_IS_TRANSITION) == true) {
|
||||||
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
window.requestFeature(Window.FEATURE_ACTIVITY_TRANSITIONS)
|
||||||
findViewById<View>(android.R.id.content)?.let { contentView ->
|
findViewById<View>(android.R.id.content)?.let { contentView ->
|
||||||
contentView.transitionName = SHARED_ELEMENT_NAME
|
contentView.transitionName = SHARED_ELEMENT_NAME
|
||||||
|
@ -168,6 +171,7 @@ class ReaderActivity : BaseRxActivity<ReaderActivityBinding, ReaderPresenter>()
|
||||||
// Postpone custom transition until manga ready
|
// Postpone custom transition until manga ready
|
||||||
postponeEnterTransition()
|
postponeEnterTransition()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
|
|
||||||
|
|
Reference in a new issue