From 1ac3a5cef20266e1019a0b4cff25ee7fc2997f40 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sat, 8 Feb 2020 20:35:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/io/legado/app/service/help/ReadBook.kt | 10 ++++++---- .../io/legado/app/ui/book/read/ReadBookViewModel.kt | 1 + 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/io/legado/app/service/help/ReadBook.kt b/app/src/main/java/io/legado/app/service/help/ReadBook.kt index f5227f731..1f62d785a 100644 --- a/app/src/main/java/io/legado/app/service/help/ReadBook.kt +++ b/app/src/main/java/io/legado/app/service/help/ReadBook.kt @@ -39,14 +39,16 @@ object ReadBook { durChapterIndex = book.durChapterIndex durPageIndex = book.durChapterPos isLocalBook = book.origin == BookType.local - webBook = null - App.db.bookSourceDao().getBookSource(book.origin)?.let { - webBook = WebBook(it) - } chapterSize = 0 prevTextChapter = null curTextChapter = null nextTextChapter = null + upWebBook(book.origin) + } + + fun upWebBook(origin: String) { + val bookSource = App.db.bookSourceDao().getBookSource(origin) + webBook = if (bookSource != null) WebBook(bookSource) else null } fun moveToNextPage() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt index ed5d9d04d..db7529cab 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookViewModel.kt @@ -60,6 +60,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } else { isInitFinish = true ReadBook.titleDate.postValue(book.name) + ReadBook.upWebBook(book.origin) ReadBook.chapterSize = App.db.bookChapterDao().getChapterCount(book.bookUrl) if (ReadBook.chapterSize == 0) { if (book.tocUrl.isEmpty()) {