pull/32/head
kunfei 5 years ago
parent b541ed2e2e
commit c674d0b9a6
  1. 9
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 11
      app/src/main/java/io/legado/app/ui/main/bookshelf/BookshelfViewModel.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<Int, Book>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg books: Book)
fun insert(vararg book: Book)
@Update
fun update(vararg books: Book)
}

@ -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)) {
}
}
}
}
}
}
}

Loading…
Cancel
Save