From 8679723300b1e2ecb5e95d9015a2385f23f27784 Mon Sep 17 00:00:00 2001 From: kunfei Date: Fri, 30 Aug 2019 14:17:37 +0800 Subject: [PATCH] up --- .../java/io/legado/app/ui/readbook/ReadBookActivity.kt | 5 +++++ .../java/io/legado/app/ui/readbook/ReadBookViewModel.kt | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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 780000f4c..46944a4ea 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 @@ -190,6 +190,7 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea override fun onCompatOptionsItemSelected(item: MenuItem): Boolean { when (item.itemId) { R.id.menu_change_source -> { + read_menu.runMenuOut() if (changeSourceDialog == null) { viewModel.bookData.value?.let { changeSourceDialog = ChangeSourceDialog @@ -287,6 +288,10 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_rea } } + override fun upContent() { + page_view.upContent() + } + private fun curChapterChanged() { viewModel.curTextChapter?.let { tv_chapter_name.text = it.title 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 78b743705..b1d706b33 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 @@ -42,7 +42,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } else { App.db.bookDao().lastReadBook } - saveRead(book) book?.let { durChapterIndex = book.durChapterIndex durPageIndex = book.durChapterPos @@ -66,6 +65,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { chapterListFinish.postValue(true) } } + saveRead(book) }.onError { it.printStackTrace() } } @@ -225,6 +225,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { bookData.value?.let { App.db.bookDao().delete(it.bookUrl) } + prevTextChapter = null + curTextChapter = null + nextTextChapter = null + callBack?.upContent() App.db.bookDao().insert(book) bookData.postValue(book) App.db.bookSourceDao().getBookSource(book.origin)?.let { @@ -321,5 +325,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { interface CallBack { fun contentLoadFinish(bookChapter: BookChapter, content: String) + fun upContent() } } \ No newline at end of file