pull/32/head
kunfei 5 years ago
parent 20fd00f165
commit 9b8a78debf
  1. 22
      app/src/main/java/io/legado/app/ui/readbook/ReadBookViewModel.kt

@ -28,18 +28,18 @@ class ReadBookViewModel(application: Application) : BaseViewModel(application) {
bookSource = App.db.bookSourceDao().getBookSource(book.origin) bookSource = App.db.bookSourceDao().getBookSource(book.origin)
bookSource?.let { bookSource?.let {
webBook = WebBook(it) webBook = WebBook(it)
val count = App.db.bookChapterDao().getChapterCount(bookUrl) }
if (count == 0) { val count = App.db.bookChapterDao().getChapterCount(bookUrl)
webBook?.getChapterList(book) if (count == 0) {
?.onSuccess { cList -> webBook?.getChapterList(book)
cList?.let { ?.onSuccess { cList ->
App.db.bookChapterDao().insert(*cList.toTypedArray()) cList?.let {
chapterMaxIndex.postValue(cList.size) App.db.bookChapterDao().insert(*cList.toTypedArray())
} chapterMaxIndex.postValue(cList.size)
} }
} else { }
chapterMaxIndex.postValue(count) } else {
} chapterMaxIndex.postValue(count)
} }
} }

Loading…
Cancel
Save