From a0fc75ba37c57084d6385da6f191ab33216c9dcf Mon Sep 17 00:00:00 2001 From: gedoor Date: Wed, 9 Sep 2020 20:57:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=87=AA=E5=8A=A8=E6=8D=A2?= =?UTF-8?q?=E6=BA=90=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../app/ui/book/read/ReadBookViewModel.kt | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) 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 0e2b4a050..7fcb65534 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 @@ -65,6 +65,7 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ReadBook.loadContent(resetPageOffset = true) } } else { + ReadBook.book = book if (ReadBook.durChapterIndex != book.durChapterIndex) { ReadBook.durChapterIndex = book.durChapterIndex ReadBook.durPageIndex = book.durChapterPos @@ -72,7 +73,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { ReadBook.curTextChapter = null ReadBook.nextTextChapter = null } - ReadBook.book!!.group = book.group ReadBook.titleDate.postValue(book.name) ReadBook.upWebBook(book) isInitFinish = true @@ -160,20 +160,24 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { execute { ReadBook.upMsg(null) ReadBook.book?.changeTo(newBook) + ReadBook.book = newBook + App.db.bookSourceDao().getBookSource(newBook.origin)?.let { + ReadBook.webBook = WebBook(it) + } ReadBook.prevTextChapter = null ReadBook.curTextChapter = null ReadBook.nextTextChapter = null withContext(Main) { ReadBook.callBack?.upContent() } - ReadBook.book = newBook - App.db.bookSourceDao().getBookSource(newBook.origin)?.let { - ReadBook.webBook = WebBook(it) - } if (newBook.tocUrl.isEmpty()) { - loadBookInfo(newBook) { upChangeDurChapterIndex(newBook, it) } + loadBookInfo(newBook) { + upChangeDurChapterIndex(newBook, it) + } } else { - loadChapterList(newBook) { upChangeDurChapterIndex(newBook, it) } + loadChapterList(newBook) { + upChangeDurChapterIndex(newBook, it) + } } } }