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 157aa7945..b1d735117 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 @@ -375,10 +375,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea /** * 下一页 */ - override fun moveToNextChapter(): Boolean { + override fun moveToNextChapter(upContent: Boolean): Boolean { return if (viewModel.durChapterIndex < viewModel.chapterSize - 1) { viewModel.durPageIndex = 0 - viewModel.moveToNextChapter() + viewModel.moveToNextChapter(upContent) viewModel.saveRead() curChapterChanged() true @@ -390,10 +390,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea /** * 上一页 */ - override fun moveToPrevChapter(last: Boolean): Boolean { + override fun moveToPrevChapter(upContent: Boolean, last: Boolean): Boolean { return if (viewModel.durChapterIndex > 0) { viewModel.durPageIndex = if (last) viewModel.prevTextChapter?.lastIndex() ?: 0 else 0 - viewModel.moveToPrevChapter() + viewModel.moveToPrevChapter(upContent) viewModel.saveRead() curChapterChanged() true @@ -586,14 +586,14 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea page_view.upContent() viewModel.saveRead() } - 2 -> if (!moveToNextChapter()) ReadAloud.stop(this) + 2 -> if (!moveToNextChapter(true)) ReadAloud.stop(this) -1 -> { if (viewModel.durPageIndex > 0) { viewModel.durPageIndex = viewModel.durPageIndex - 1 page_view.upContent() viewModel.saveRead() } else { - moveToPrevChapter() + moveToPrevChapter(true) } } -2 -> moveToPrevChapter(false) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index 635deb97e..a0b02a402 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -108,7 +108,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } } - fun moveToNextChapter() { + fun moveToNextChapter(upContent: Boolean) { durChapterIndex++ prevTextChapter = curTextChapter curTextChapter = nextTextChapter @@ -116,7 +116,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { bookData.value?.let { if (curTextChapter == null) { loadContent(it, durChapterIndex) - } else { + } else if (upContent) { callBack?.upContent() } loadContent(it, durChapterIndex.plus(1)) @@ -131,7 +131,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } } - fun moveToPrevChapter() { + fun moveToPrevChapter(upContent: Boolean) { durChapterIndex-- nextTextChapter = curTextChapter curTextChapter = prevTextChapter @@ -139,7 +139,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { bookData.value?.let { if (curTextChapter == null) { loadContent(it, durChapterIndex) - } else { + } else if (upContent) { callBack?.upContent() } loadContent(it, durChapterIndex.minus(1)) 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 af02fa16c..bb321fd65 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 @@ -153,10 +153,10 @@ class ReadMenu : FrameLayout { } //上一章 - tv_pre.onClick { callBack?.moveToPrevChapter(false) } + tv_pre.onClick { callBack?.moveToPrevChapter(upContent = true, last = false) } //下一章 - tv_next.onClick { callBack?.moveToNextChapter() } + tv_next.onClick { callBack?.moveToNextChapter(true) } //目录 ll_catalog.onClick { @@ -250,8 +250,8 @@ class ReadMenu : FrameLayout { interface CallBack { fun autoPage() fun skipToPage(page: Int) - fun moveToPrevChapter(last: Boolean): Boolean - fun moveToNextChapter(): Boolean + fun moveToPrevChapter(upContent: Boolean, last: Boolean): Boolean + fun moveToNextChapter(upContent: Boolean): Boolean fun openReplaceRule() fun openChapterList() fun showReadStyle() diff --git a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt index 72aa4b4ef..899937b37 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/PageView.kt @@ -208,11 +208,11 @@ class PageView(context: Context, attrs: AttributeSet) : } override fun moveToNextChapter() { - callback?.moveToNextChapter() + callback?.moveToNextChapter(false) } override fun moveToPrevChapter() { - callback?.moveToPrevChapter() + callback?.moveToPrevChapter(false) } override fun scrollToLine(line: Int) { @@ -241,12 +241,12 @@ class PageView(context: Context, attrs: AttributeSet) : /** * 下一章 */ - fun moveToNextChapter(): Boolean + fun moveToNextChapter(upContent: Boolean): Boolean /** * 上一章 */ - fun moveToPrevChapter(last: Boolean = true): Boolean + fun moveToPrevChapter(upContent: Boolean, last: Boolean = true): Boolean /** * 保存页数