From 0871341b21e5348dd83c11109b57f57704222382 Mon Sep 17 00:00:00 2001 From: bushixuanqi <57338301+bushixuanqi@users.noreply.github.com> Date: Sat, 17 Jul 2021 02:19:51 +0800 Subject: [PATCH] Update ReadBook.kt MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 优化 --- .../io/legado/app/service/help/ReadBook.kt | 32 +++++++------------ 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index 56a8f4bb7..f2b765b9b 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -415,30 +415,22 @@ object ReadBook { else -> chapter.title } val contents = contentProcessor!!.getContent(book, chapter.title, content) - when (chapter.index) { - durChapterIndex -> { - curTextChapter = - ChapterProvider.getTextChapter( - book, chapter, contents, chapterSize - ) - if (upContent) callBack?.upContent(resetPageOffset = resetPageOffset) + val textChapter = ChapterProvider.getTextChapter(book, chapter,contents,chapterSize) + + val offset = chapter.index - durChapterIndex + if (upContent) callBack?.upContent(offset ,resetPageOffset) + when (offset) { + 0 -> { + curTextChapter = textChapter callBack?.upView() curPageChanged() callBack?.contentLoadFinish() } - durChapterIndex - 1 -> { - prevTextChapter = - ChapterProvider.getTextChapter( - book, chapter, contents, chapterSize - ) - if (upContent) callBack?.upContent(-1, resetPageOffset) + - 1 -> { + prevTextChapter = textChapter } - durChapterIndex + 1 -> { - nextTextChapter = - ChapterProvider.getTextChapter( - book, chapter, contents, chapterSize - ) - if (upContent) callBack?.upContent(1, resetPageOffset) + 1 -> { + nextTextChapter = textChapter } } } @@ -501,4 +493,4 @@ object ReadBook { fun upPageAnim() } -} \ No newline at end of file +}