From df30bcafd00ae28b4adac22e0bd4da08f45de5b3 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 25 Aug 2019 22:32:28 +0800 Subject: [PATCH] up --- .../app/ui/readbook/ReadBookActivity.kt | 29 ++++++++++++------- .../app/ui/widget/page/ChapterProvider.kt | 9 ++++-- .../legado/app/ui/widget/page/TextChapter.kt | 1 + 3 files changed, 26 insertions(+), 13 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 c7c913e52..ea59fb2e5 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 @@ -224,17 +224,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea launch { when (bookChapter.index) { viewModel.durChapterIndex -> { - tv_chapter_name.text = bookChapter.title - tv_chapter_name.visible() - if (!viewModel.isLocalBook) { - tv_chapter_url.text = bookChapter.url - tv_chapter_url.visible() - } - ChapterProvider.getTextChapter(content_text_view, bookChapter, content).let { - viewModel.curTextChapter = it - page_view.upContent() - read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex) - } + viewModel.curTextChapter = + ChapterProvider.getTextChapter(content_text_view, bookChapter, content) + page_view.upContent() + curChapterChange() } viewModel.durChapterIndex - 1 -> { viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content) @@ -248,6 +241,18 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } } + private fun curChapterChange() { + viewModel.curTextChapter?.let { + tv_chapter_name.text = it.title + tv_chapter_name.visible() + if (!viewModel.isLocalBook) { + tv_chapter_url.text = it.url + tv_chapter_url.visible() + } + read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex) + } + } + override fun chapterSize(): Int { return viewModel.chapterSize } @@ -293,10 +298,12 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea override fun moveToNextChapter() { viewModel.moveToNextChapter() + curChapterChange() } override fun moveToPrevChapter() { viewModel.moveToPrevChapter() + curChapterChange() } override fun clickCenter() { diff --git a/app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt b/app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt index 8aa4fffde..d24e411d2 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/ChapterProvider.kt @@ -45,8 +45,13 @@ object ChapterProvider { pageIndex++ } - return TextChapter(bookChapter.index, bookChapter.title, textPages, pageLengths) + return TextChapter( + bookChapter.index, + bookChapter.title, + bookChapter.url, + textPages, + pageLengths + ) } - } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt b/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt index d63c7b526..60df9a04a 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/TextChapter.kt @@ -3,6 +3,7 @@ package io.legado.app.ui.widget.page data class TextChapter( val position: Int, val title: String, + val url: String, val pages: List, val pageLengths: List ) {