From 37666eea94700f0f249060d0fab30df8ea2eb38e Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 25 Aug 2019 22:09:51 +0800 Subject: [PATCH] up --- .../app/ui/readbook/ReadBookActivity.kt | 8 +-- .../io/legado/app/ui/widget/page/PageView.kt | 50 +++---------------- 2 files changed, 12 insertions(+), 46 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 783d79a97..c7c913e52 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 @@ -113,7 +113,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea override fun skipToPage(page: Int) { viewModel.durPageIndex = page - page_view.chapterLoadFinish() + page_view.upContent() } override fun skipPreChapter() { @@ -232,17 +232,17 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } ChapterProvider.getTextChapter(content_text_view, bookChapter, content).let { viewModel.curTextChapter = it - page_view.chapterLoadFinish() + page_view.upContent() read_menu.upReadProgress(it.pageSize(), viewModel.durPageIndex) } } viewModel.durChapterIndex - 1 -> { viewModel.prevTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content) - page_view.chapterLoadFinish(-1) + page_view.upContent() } viewModel.durChapterIndex + 1 -> { viewModel.nextTextChapter = ChapterProvider.getTextChapter(content_text_view, bookChapter, content) - page_view.chapterLoadFinish(1) + page_view.upContent() } } } 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 6d665ceef..0626f0d14 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 @@ -110,40 +110,6 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att return pageDelegate?.onTouch(event) ?: super.onTouchEvent(event) } - fun chapterLoadFinish(chapterOnDur: Int = 0) { - callback?.let { cb -> - when (chapterOnDur) { - 0 -> { - cb.textChapter()?.let { - curPage?.setContent(it.page(cb.durChapterPos())) - if (cb.durChapterPos() > 0) { - prevPage?.setContent(it.page(cb.durChapterPos().minus(1))) - } - if (cb.durChapterPos() < it.pageSize().minus(1)) { - nextPage?.setContent(it.page(cb.durChapterPos().plus(1))) - } - } - } - 1 -> { - cb.textChapter()?.let { - if (cb.durChapterPos() == it.pageSize().minus(1)) { - nextPage?.setContent(cb.textChapter(1)?.page(0)) - } - } - } - -1 -> { - cb.textChapter()?.let { - if (cb.durChapterPos() == 0) { - prevPage?.setContent(cb.textChapter(-1)?.lastPage()) - } - } - } - else -> { - } - } - } - } - fun fillPage(direction: PageDelegate.Direction) { pageFactory?.let { when (direction) { @@ -172,14 +138,6 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att upContent() } - override fun hasNext(): Boolean { - return true - } - - override fun hasPrev(): Boolean { - return true - } - fun upContent() { pageFactory?.let { prevPage?.setContent(it.previousPage()) @@ -188,6 +146,14 @@ class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, att } } + override fun hasNext(): Boolean { + return true + } + + override fun hasPrev(): Boolean { + return true + } + fun upStyle() { curPage?.upStyle() prevPage?.upStyle()