From 8fdf876456ea6da458e7c0fce1ba05da8ec09b03 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 7 Sep 2019 21:26:27 +0800 Subject: [PATCH] up --- .../app/ui/readbook/ReadBookActivity.kt | 32 ++++++++++++------- .../io/legado/app/ui/readbook/ReadMenu.kt | 4 +-- .../io/legado/app/ui/widget/page/PageView.kt | 8 ++--- 3 files changed, 27 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt index b47f6001a..e070950d6 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookActivity.kt @@ -372,21 +372,31 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea /** * 下一页 */ - override fun moveToNextChapter() { - viewModel.durPageIndex = 0 - viewModel.moveToNextChapter() - viewModel.saveRead() - curChapterChanged() + override fun moveToNextChapter(): Boolean { + return if (viewModel.durChapterIndex < viewModel.chapterSize - 1) { + viewModel.durPageIndex = 0 + viewModel.moveToNextChapter() + viewModel.saveRead() + curChapterChanged() + true + } else { + false + } } /** * 上一页 */ - override fun moveToPrevChapter(last: Boolean) { - viewModel.durPageIndex = if (last) viewModel.prevTextChapter?.lastIndex() ?: 0 else 0 - viewModel.moveToPrevChapter() - viewModel.saveRead() - curChapterChanged() + override fun moveToPrevChapter(last: Boolean): Boolean { + return if (viewModel.durChapterIndex > 0) { + viewModel.durPageIndex = if (last) viewModel.prevTextChapter?.lastIndex() ?: 0 else 0 + viewModel.moveToPrevChapter() + viewModel.saveRead() + curChapterChanged() + true + } else { + false + } } override fun clickCenter() { @@ -557,7 +567,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea page_view.upContent() viewModel.saveRead() } - 2 -> moveToNextChapter() + 2 -> if (moveToNextChapter()) ReadAloudService.stop(this) -1 -> { if (viewModel.durPageIndex > 0) { viewModel.durPageIndex = viewModel.durPageIndex - 1 diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt index b15272816..c9b15348a 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadMenu.kt @@ -249,8 +249,8 @@ class ReadMenu : FrameLayout { interface CallBack { fun autoPage() fun skipToPage(page: Int) - fun moveToPrevChapter(last: Boolean) - fun moveToNextChapter() + fun moveToPrevChapter(last: Boolean): Boolean + fun moveToNextChapter(): 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 db51ab9e0..e64df6781 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 @@ -220,14 +220,14 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att fun loadContent(index: Int) /** - * 下一页 + * 下一章 */ - fun moveToNextChapter() + fun moveToNextChapter(): Boolean /** - * 上一页 + * 上一章 */ - fun moveToPrevChapter(last: Boolean = true) + fun moveToPrevChapter(last: Boolean = true): Boolean /** * 保存页数