From c4c70fb197cb34db6568c44d1ef1e77104d3d1fa Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 3 Nov 2021 21:16:07 +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 --- app/src/main/java/io/legado/app/model/ReadBook.kt | 13 ++++++++++++- .../io/legado/app/ui/book/read/ReadBookViewModel.kt | 10 +--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/io/legado/app/model/ReadBook.kt b/app/src/main/java/io/legado/app/model/ReadBook.kt index e7d105bad..cbf85bf4f 100644 --- a/app/src/main/java/io/legado/app/model/ReadBook.kt +++ b/app/src/main/java/io/legado/app/model/ReadBook.kt @@ -52,7 +52,6 @@ object ReadBook : CoroutineScope by MainScope() { durChapterIndex = book.durChapterIndex durChapterPos = book.durChapterPos isLocalBook = book.origin == BookType.local - chapterSize = book.totalChapterNum clearTextChapter() callBack?.upMenuView() callBack?.upPageAnim() @@ -63,6 +62,18 @@ object ReadBook : CoroutineScope by MainScope() { } } + fun upData(book: Book) { + ReadBook.book = book + chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl) + if (durChapterIndex != book.durChapterIndex) { + durChapterIndex = book.durChapterIndex + durChapterPos = book.durChapterPos + clearTextChapter() + } + callBack?.upMenuView() + upWebBook(book) + } + fun upWebBook(book: Book) { if (book.origin == BookType.local) { bookSource = null 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 d5f016c18..34a026e8e 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 @@ -68,16 +68,8 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { } syncBookProgress(book) } else { - ReadBook.book = book - if (ReadBook.durChapterIndex != book.durChapterIndex) { - ReadBook.durChapterIndex = book.durChapterIndex - ReadBook.durChapterPos = book.durChapterPos - ReadBook.clearTextChapter() - } - ReadBook.callBack?.upMenuView() - ReadBook.upWebBook(book) + ReadBook.upData(book) isInitFinish = true - ReadBook.chapterSize = appDb.bookChapterDao.getChapterCount(book.bookUrl) if (ReadBook.chapterSize == 0) { if (book.tocUrl.isEmpty()) { loadBookInfo(book)