From cc1768038eab0bf71a8697cd425f35dcd4e12d7f Mon Sep 17 00:00:00 2001 From: kunfei Date: Wed, 14 Aug 2019 15:19:00 +0800 Subject: [PATCH] up --- .../main/java/io/legado/app/ui/read/ReadViewModel.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt b/app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt index fed906c6b..7f45b52c2 100644 --- a/app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/read/ReadViewModel.kt @@ -6,6 +6,7 @@ import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.data.entities.Book import io.legado.app.data.entities.BookSource +import io.legado.app.model.WebBook class ReadViewModel(application: Application) : BaseViewModel(application) { @@ -19,8 +20,14 @@ class ReadViewModel(application: Application) : BaseViewModel(application) { book = App.db.bookDao().getBook(bookUrl) book?.let { book -> if (App.db.bookChapterDao().getChapterCount(bookUrl) == 0) { - bookSource = App.db.bookSourceDao().getBookSource(book.origin) - if (bookSource == null) { + App.db.bookSourceDao().getBookSource(book.origin)?.let { + WebBook(it).getChapterList(book) + .onSuccess { cList -> + cList?.let { + App.db.bookChapterDao().insert(*cList.toTypedArray()) + } + } + } ?: let { } }