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)