阅读界面菜单显示的时候停止按键翻页和自动阅读

pull/1198/head
gedoor 3 years ago
parent 3d34edf4e6
commit 796732f97d
  1. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@ -125,6 +125,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
private var loadStates: Boolean = false
override val pageFactory: TextPageFactory get() = binding.readView.pageFactory
override val headerHeight: Int get() = binding.readView.curPage.headerHeight
private val menuLayoutIsVisible get() = bottomDialog > 0 || binding.readMenu.isVisible
@SuppressLint("ClickableViewAccessibility")
override fun onActivityCreated(savedInstanceState: Bundle?) {
@ -330,6 +331,9 @@ class ReadBookActivity : ReadBookBaseActivity(),
* 按键事件
*/
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
if (menuLayoutIsVisible) {
return super.onKeyDown(keyCode, event)
}
when {
isPrevKey(keyCode) -> {
if (keyCode != KeyEvent.KEYCODE_UNKNOWN) {
@ -699,6 +703,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
delayMillis = 20
}
mHandler.removeCallbacks(autoPageRunnable)
if (!menuLayoutIsVisible) {
if (binding.readView.isScroll) {
binding.readView.curPage.scroll(-scrollOffset)
} else {
@ -712,6 +717,7 @@ class ReadBookActivity : ReadBookBaseActivity(),
binding.readView.invalidate()
}
}
}
mHandler.postDelayed(autoPageRunnable, delayMillis)
}

Loading…
Cancel
Save