From 945217f505d6c8661b1d4189ee152d8d68f6b955 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 18 Aug 2019 17:27:27 +0800 Subject: [PATCH] up --- .../io/legado/app/ui/readbook/ReadBookActivity.kt | 6 ++++-- .../java/io/legado/app/ui/widget/page/PageView.kt | 12 ++++++++++-- .../java/io/legado/app/ui/widget/page/TextChapter.kt | 7 +++++++ 3 files changed, 21 insertions(+), 4 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 dd3965889..ba77137cc 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 @@ -237,8 +237,8 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea private fun bookLoadFinish() { viewModel.bookData.value?.let { viewModel.loadContent(it, it.durChapterIndex) -// viewModel.loadContent(it, it.durChapterIndex + 1) -// viewModel.loadContent(it, it.durChapterIndex - 1) + viewModel.loadContent(it, it.durChapterIndex + 1) + viewModel.loadContent(it, it.durChapterIndex - 1) } } @@ -257,9 +257,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } viewModel.durChapterIndex - 1 -> { viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content) + page_view.chapterLoadFinish(-1) } viewModel.durChapterIndex + 1 -> { viewModel.nextTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content) + page_view.chapterLoadFinish(1) } } } 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 e02bc8b6d..25f9eefcb 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 @@ -74,10 +74,18 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att } } 1 -> { - + cb.textChapter()?.let { + if (cb.durChapterPos(it.pageSize()) == it.pageSize() - 1) { + nextPage?.setContent(cb.textChapter(1)?.page(0)?.text) + } + } } -1 -> { - + cb.textChapter()?.let { + if (cb.durChapterPos(it.pageSize()) == 0) { + prevPage?.setContent(cb.textChapter(-1)?.lastPage()?.text) + } + } } else -> { } 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 032a732c1..8f913d92c 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 @@ -13,6 +13,13 @@ data class TextChapter( return null } + fun lastPage(): TextPage? { + if (pages.isNotEmpty()) { + return pages[pages.lastIndex] + } + return null + } + fun pageSize(): Int { return pages.size }