pull/1319/head
gedoor 3 years ago
parent acc7199551
commit 04c02c1120
  1. 10
      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.postEvent
import io.legado.app.utils.toastOnUi import io.legado.app.utils.toastOnUi
import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.Dispatchers.Main
import kotlinx.coroutines.withContext
class ReadBookViewModel(application: Application) : BaseViewModel(application) { class ReadBookViewModel(application: Application) : BaseViewModel(application) {
var isInitFinish = false var isInitFinish = false
@ -187,16 +185,10 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
fun changeTo(newBook: Book) { fun changeTo(newBook: Book) {
execute { execute {
var oldTocSize: Int = newBook.totalChapterNum val oldTocSize: Int = ReadBook.book?.totalChapterNum ?: newBook.totalChapterNum
ReadBook.upMsg(null) ReadBook.upMsg(null)
ReadBook.book?.let {
oldTocSize = it.totalChapterNum
it.changeTo(newBook)
}
ReadBook.resetData(newBook) ReadBook.resetData(newBook)
withContext(Main) {
ReadBook.callBack?.upContent() ReadBook.callBack?.upContent()
}
if (newBook.tocUrl.isEmpty()) { if (newBook.tocUrl.isEmpty()) {
loadBookInfo(newBook) { loadBookInfo(newBook) {
upChangeDurChapterIndex(newBook, oldTocSize, it) upChangeDurChapterIndex(newBook, oldTocSize, it)

Loading…
Cancel
Save