|
|
|
@ -102,7 +102,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
book: Book, |
|
|
|
|
changeDruChapterIndex: ((chapters: List<BookChapter>) -> Unit)? = null, |
|
|
|
|
) { |
|
|
|
|
execute { |
|
|
|
|
if (book.isLocalBook()) { |
|
|
|
|
loadChapterList(book, changeDruChapterIndex) |
|
|
|
|
} else { |
|
|
|
@ -112,14 +111,13 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun loadChapterList( |
|
|
|
|
book: Book, |
|
|
|
|
changeDruChapterIndex: ((chapters: List<BookChapter>) -> Unit)? = null, |
|
|
|
|
) { |
|
|
|
|
execute { |
|
|
|
|
if (book.isLocalBook()) { |
|
|
|
|
execute { |
|
|
|
|
LocalBook.getChapterList(book).let { |
|
|
|
|
App.db.bookChapterDao().delByBook(book.bookUrl) |
|
|
|
|
App.db.bookChapterDao().insert(*it.toTypedArray()) |
|
|
|
@ -132,6 +130,9 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
ReadBook.loadContent(resetPageOffset = true) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}.onError { |
|
|
|
|
ReadBook.upMsg("LoadTocError:${it.localizedMessage}") |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
ReadBook.webBook?.getChapterList(book, this) |
|
|
|
|
?.onSuccess(IO) { cList -> |
|
|
|
@ -152,9 +153,6 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) { |
|
|
|
|
ReadBook.upMsg(context.getString(R.string.error_load_toc)) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}.onError { |
|
|
|
|
ReadBook.upMsg("LoadTocError:${it.localizedMessage}") |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fun changeTo(newBook: Book) { |
|
|
|
|