pull/43/head
kunfei 5 years ago
parent b5cd3fcfe9
commit e2c2d9e408
  1. 14
      app/src/main/java/io/legado/app/ui/book/info/BookInfoViewModel.kt

@ -43,12 +43,16 @@ class BookInfoViewModel(application: Application) : BaseViewModel(application) {
private fun setBook(book: Book) {
durChapterIndex = book.durChapterIndex
bookData.postValue(book)
val chapterList = App.db.bookChapterDao().getChapterList(book.bookUrl)
if (chapterList.isNotEmpty()) {
chapterListData.postValue(chapterList)
isLoadingData.postValue(false)
if (book.tocUrl.isEmpty()) {
loadBookInfo(book)
} else {
loadChapter(book)
val chapterList = App.db.bookChapterDao().getChapterList(book.bookUrl)
if (chapterList.isNotEmpty()) {
chapterListData.postValue(chapterList)
isLoadingData.postValue(false)
} else {
loadChapter(book)
}
}
}

Loading…
Cancel
Save