diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index e2448820d..4fd108074 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -153,22 +153,22 @@ class ReadBookActivity : ReadBookBaseActivity(), } private fun upMenu() { - menu?.let { menu -> - ReadBook.book?.let { book -> - val onLine = !book.isLocalBook() - for (i in 0 until menu.size) { - val item = menu[i] - when (item.groupId) { - R.id.menu_group_on_line, - R.id.menu_group_on_line_ns -> item.isVisible = onLine - R.id.menu_group_local -> item.isVisible = !onLine - R.id.menu_group_text -> item.isVisible = book.isLocalTxt() - R.id.menu_group_login -> - item.isVisible = !ReadBook.webBook?.bookSource?.loginUrl.isNullOrEmpty() - else -> when (item.itemId) { - R.id.menu_enable_replace -> item.isChecked = book.getUseReplaceRule() - R.id.menu_re_segment -> item.isChecked = book.getReSegment() - } + val menu = menu + val book = ReadBook.book + if (menu != null && book != null) { + val onLine = !book.isLocalBook() + for (i in 0 until menu.size) { + val item = menu[i] + when (item.groupId) { + R.id.menu_group_on_line, + R.id.menu_group_on_line_ns -> item.isVisible = onLine + R.id.menu_group_local -> item.isVisible = !onLine + R.id.menu_group_text -> item.isVisible = book.isLocalTxt() + R.id.menu_group_login -> + item.isVisible = !ReadBook.webBook?.bookSource?.loginUrl.isNullOrEmpty() + else -> when (item.itemId) { + R.id.menu_enable_replace -> item.isChecked = book.getUseReplaceRule() + R.id.menu_re_segment -> item.isChecked = book.getReSegment() } } } @@ -581,14 +581,15 @@ class ReadBookActivity : ReadBookBaseActivity(), binding.readView.upContent() binding.readView.upContent(1) autoPagePlus() + binding.readMenu.setAutoPage(true) } - binding.readMenu.setAutoPage(isAutoPage) } override fun autoPageStop() { isAutoPage = false mHandler.removeCallbacks(autoPageRunnable) binding.readView.upContent() + binding.readMenu.setAutoPage(false) } private fun autoPagePlus() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index c22eca629..a73f3d4a2 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -300,15 +300,15 @@ class ReadMenu @JvmOverloads constructor( binding.seekReadPage.progress = seek } - fun setAutoPage(autoPage: Boolean) { + fun setAutoPage(autoPage: Boolean) = with(binding) { if (autoPage) { - binding.fabAutoPage.setImageResource(R.drawable.ic_auto_page_stop) - binding.fabAutoPage.contentDescription = context.getString(R.string.auto_next_page_stop) + fabAutoPage.setImageResource(R.drawable.ic_auto_page_stop) + fabAutoPage.contentDescription = context.getString(R.string.auto_next_page_stop) } else { - binding.fabAutoPage.setImageResource(R.drawable.ic_auto_page) - binding.fabAutoPage.contentDescription = context.getString(R.string.auto_next_page) + fabAutoPage.setImageResource(R.drawable.ic_auto_page) + fabAutoPage.contentDescription = context.getString(R.string.auto_next_page) } - binding.fabAutoPage.setColorFilter(textColor) + fabAutoPage.setColorFilter(textColor) } interface CallBack {