Fixed reader menu quickly disappearing when first opening

This commit is contained in:
Jays2Kings 2021-10-07 23:47:56 -04:00
parent 0816b62721
commit dbac0aa48d

View file

@ -750,7 +750,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
} }
// Set initial visibility // Set initial visibility
setMenuVisibility(menuVisible) setMenuVisibility(menuVisible, false)
binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = !menuVisible binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.isHideable = !menuVisible
if (!menuVisible) binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.hide() if (!menuVisible) binding.chaptersSheet.chaptersBottomSheet.sheetBehavior?.hide()
binding.chaptersSheet.root.sheetBehavior?.isGestureInsetBottomIgnored = true binding.chaptersSheet.root.sheetBehavior?.isGestureInsetBottomIgnored = true
@ -879,6 +879,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
* [animate] the views. * [animate] the views.
*/ */
private fun setMenuVisibility(visible: Boolean, animate: Boolean = true) { private fun setMenuVisibility(visible: Boolean, animate: Boolean = true) {
val oldVisibility = menuVisible
menuVisible = visible menuVisible = visible
if (visible) coroutine?.cancel() if (visible) coroutine?.cancel()
binding.viewerContainer.requestLayout() binding.viewerContainer.requestLayout()
@ -893,7 +894,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
if (!binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded() && sheetManageNavColor) { if (!binding.chaptersSheet.chaptersBottomSheet.sheetBehavior.isExpanded() && sheetManageNavColor) {
window.navigationBarColor = Color.TRANSPARENT window.navigationBarColor = Color.TRANSPARENT
} }
if (animate) { if (animate && oldVisibility != menuVisible) {
if (!menuStickyVisible) { if (!menuStickyVisible) {
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top)
toolbarAnimation.setAnimationListener( toolbarAnimation.setAnimationListener(
@ -912,7 +913,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
wic.hide(systemBars()) wic.hide(systemBars())
} }
if (animate) { if (animate && oldVisibility != menuVisible) {
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top) val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top)
toolbarAnimation.setAnimationListener( toolbarAnimation.setAnimationListener(
object : SimpleAnimationListener() { object : SimpleAnimationListener() {