From 45994f363954be8e5edb9c20f583af163a825f16 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 26 Aug 2019 08:11:40 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/readbook/ReadBookActivity.kt | 7 +++++-- .../java/io/legado/app/ui/readbook/ReadBookViewModel.kt | 3 +++ 2 files changed, 8 insertions(+), 2 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 248400518..2c2ff3def 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 @@ -412,7 +412,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea observeEvent(Bus.ALOUD_STATE) { readAloudStatus = it } observeEvent(Bus.TIME_CHANGED) { page_view.upTime() } observeEvent(Bus.BATTERY_CHANGED) { page_view.upBattery(it) } - observeEvent(Bus.OPEN_CHAPTER) { viewModel.openChapter(it) } + observeEvent(Bus.OPEN_CHAPTER) { + viewModel.openChapter(it) + page_view.upContent() + } observeEventSticky(Bus.READ_ALOUD) { onClickReadAloud() } observeEvent(Bus.UP_CONFIG) { Help.upSystemUiVisibility(window, !read_menu.isVisible) @@ -428,7 +431,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea if (page != null && page.text is SpannableStringBuilder) { page.text.removeSpan(ChapterProvider.readAloudSpan) var end = page.text.indexOf("\n", pageStart) - if (end == -1) end = page.text.length - 1 + if (end == -1) end = page.text.length var start = page.text.lastIndexOf("\n", pageStart) if (start == -1) start = 0 page.text.setSpan( diff --git a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt index 45fd04c68..7dcd4254d 100644 --- a/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt @@ -171,6 +171,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } fun openChapter(chapter: BookChapter) { + prevTextChapter = null + curTextChapter = null + nextTextChapter = null if (chapter.index != durChapterIndex) { durChapterIndex = chapter.index durPageIndex = 0