From 31b1b83606236817de86040196717e34ab3f303b Mon Sep 17 00:00:00 2001 From: len Date: Sat, 30 Jul 2016 17:43:16 +0200 Subject: [PATCH] Fix #408 --- .../tachiyomi/ui/reader/ReaderActivity.kt | 54 +++++++++++-------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index bf90a10810..a87a895961 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -149,6 +149,13 @@ class ReaderActivity : BaseRxActivity() { super.onSaveInstanceState(outState) } + override fun onWindowFocusChanged(hasFocus: Boolean) { + super.onWindowFocusChanged(hasFocus) + if (hasFocus) { + setMenuVisibility(menuVisible, animate = false) + } + } + override fun onBackPressed() { val chapterToUpdate = presenter.getMangaSyncChapterToUpdate() @@ -463,37 +470,42 @@ class ReaderActivity : BaseRxActivity() { } } - private fun setMenuVisibility(visible: Boolean) { + private fun setMenuVisibility(visible: Boolean, animate: Boolean = true) { menuVisible = visible if (visible) { systemUi?.show() reader_menu.visibility = View.VISIBLE - val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) - toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { - override fun onAnimationStart(animation: Animation) { - // Fix status bar being translucent the first time it's opened. - if (Build.VERSION.SDK_INT >= 21) { - window.addFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) + if (animate) { + val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) + toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { + override fun onAnimationStart(animation: Animation) { + // Fix status bar being translucent the first time it's opened. + if (Build.VERSION.SDK_INT >= 21) { + window.addFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) + } } - } - }) - toolbar.startAnimation(toolbarAnimation) + }) + toolbar.startAnimation(toolbarAnimation) - val bottomMenuAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom) - reader_menu_bottom.startAnimation(bottomMenuAnimation) + val bottomMenuAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom) + reader_menu_bottom.startAnimation(bottomMenuAnimation) + } } else { systemUi?.hide() - val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top) - toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { - override fun onAnimationEnd(animation: Animation) { - reader_menu.visibility = View.GONE - } - }) - toolbar.startAnimation(toolbarAnimation) - val bottomMenuAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_bottom) - reader_menu_bottom.startAnimation(bottomMenuAnimation) + if (animate) { + val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_top) + toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { + override fun onAnimationEnd(animation: Animation) { + reader_menu.visibility = View.GONE + } + }) + toolbar.startAnimation(toolbarAnimation) + + val bottomMenuAnimation = AnimationUtils.loadAnimation(this, R.anim.exit_to_bottom) + reader_menu_bottom.startAnimation(bottomMenuAnimation) + } } }