From c674d0b9a6246adaa19c662bb30b6267f97957de Mon Sep 17 00:00:00 2001 From: kunfei Date: Tue, 13 Aug 2019 22:21:47 +0800 Subject: [PATCH] up --- app/src/main/java/io/legado/app/data/dao/BookDao.kt | 9 ++++----- .../app/ui/main/bookshelf/BookshelfViewModel.kt | 11 +++++++++++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookDao.kt b/app/src/main/java/io/legado/app/data/dao/BookDao.kt index f1afa562e..523aca465 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookDao.kt @@ -2,10 +2,7 @@ package io.legado.app.data.dao import androidx.lifecycle.LiveData import androidx.paging.DataSource -import androidx.room.Dao -import androidx.room.Insert -import androidx.room.OnConflictStrategy -import androidx.room.Query +import androidx.room.* import io.legado.app.constant.BookType import io.legado.app.data.entities.Book @@ -46,6 +43,8 @@ interface BookDao { fun getRecentRead(): DataSource.Factory @Insert(onConflict = OnConflictStrategy.REPLACE) - fun insert(vararg books: Book) + fun insert(vararg book: Book) + @Update + fun update(vararg books: Book) } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt index a146bf845..148c20b6a 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.kt @@ -5,6 +5,8 @@ import io.legado.app.App import io.legado.app.base.BaseViewModel import io.legado.app.constant.BookType import io.legado.app.data.entities.BookGroup +import io.legado.app.model.WebBook +import kotlinx.coroutines.Dispatchers.IO class BookshelfViewModel(application: Application) : BaseViewModel(application) { @@ -27,6 +29,15 @@ class BookshelfViewModel(application: Application) : BaseViewModel(application) App.db.bookDao().getRecentRead().map { book -> if (book.origin != BookType.local) { val bookSource = App.db.bookSourceDao().getBookSource(book.origin) + bookSource?.let { + WebBook(bookSource).getChapterList(book).onSuccess(IO) { + it?.let { + if (it.size > App.db.bookChapterDao().getChapterCount(book.bookUrl)) { + + } + } + } + } } } }