This commit is contained in:
len 2016-07-30 17:43:16 +02:00
parent a5d4f63281
commit 31b1b83606

View File

@ -149,6 +149,13 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
super.onSaveInstanceState(outState) super.onSaveInstanceState(outState)
} }
override fun onWindowFocusChanged(hasFocus: Boolean) {
super.onWindowFocusChanged(hasFocus)
if (hasFocus) {
setMenuVisibility(menuVisible, animate = false)
}
}
override fun onBackPressed() { override fun onBackPressed() {
val chapterToUpdate = presenter.getMangaSyncChapterToUpdate() val chapterToUpdate = presenter.getMangaSyncChapterToUpdate()
@ -463,37 +470,42 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
} }
} }
private fun setMenuVisibility(visible: Boolean) { private fun setMenuVisibility(visible: Boolean, animate: Boolean = true) {
menuVisible = visible menuVisible = visible
if (visible) { if (visible) {
systemUi?.show() systemUi?.show()
reader_menu.visibility = View.VISIBLE reader_menu.visibility = View.VISIBLE
val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top) if (animate) {
toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() { val toolbarAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_top)
override fun onAnimationStart(animation: Animation) { toolbarAnimation.setAnimationListener(object : SimpleAnimationListener() {
// Fix status bar being translucent the first time it's opened. override fun onAnimationStart(animation: Animation) {
if (Build.VERSION.SDK_INT >= 21) { // Fix status bar being translucent the first time it's opened.
window.addFlags(FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS) 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) val bottomMenuAnimation = AnimationUtils.loadAnimation(this, R.anim.enter_from_bottom)
reader_menu_bottom.startAnimation(bottomMenuAnimation) reader_menu_bottom.startAnimation(bottomMenuAnimation)
}
} else { } else {
systemUi?.hide() 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) if (animate) {
reader_menu_bottom.startAnimation(bottomMenuAnimation) 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)
}
} }
} }