From 04c02c11204938115888a3de8d04a34f9ffebb70 Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 14 Sep 2021 12:34:37 +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 --- .../io/legado/app/ui/book/read/ReadBookViewModel.kt | 12 ++---------- 1 file changed, 2 insertions(+), 10 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 8e3707092..3f847493e 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 @@ -24,8 +24,6 @@ import io.legado.app.utils.msg import io.legado.app.utils.postEvent import io.legado.app.utils.toastOnUi import kotlinx.coroutines.Dispatchers.IO -import kotlinx.coroutines.Dispatchers.Main -import kotlinx.coroutines.withContext class ReadBookViewModel(application: Application) : BaseViewModel(application) { var isInitFinish = false @@ -187,16 +185,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { fun changeTo(newBook: Book) { execute { - var oldTocSize: Int = newBook.totalChapterNum + val oldTocSize: Int = ReadBook.book?.totalChapterNum ?: newBook.totalChapterNum ReadBook.upMsg(null) - ReadBook.book?.let { - oldTocSize = it.totalChapterNum - it.changeTo(newBook) - } ReadBook.resetData(newBook) - withContext(Main) { - ReadBook.callBack?.upContent() - } + ReadBook.callBack?.upContent() if (newBook.tocUrl.isEmpty()) { loadBookInfo(newBook) { upChangeDurChapterIndex(newBook, oldTocSize, it)