pull/35/head
kunfei 5 years ago
parent d3d0265bd7
commit 7ba212b449
  1. 13
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 2
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt

@ -9,13 +9,13 @@ import io.legado.app.data.entities.Book
@Dao
interface BookDao {
@Query("SELECT * FROM books")
@Query("SELECT * FROM books order by durChapterTime desc")
fun observeAll(): DataSource.Factory<Int, Book>
@Query("SELECT * FROM books WHERE type = ${BookType.audio}")
@Query("SELECT * FROM books WHERE type = ${BookType.audio} order by durChapterTime desc")
fun observeAudio(): DataSource.Factory<Int, Book>
@Query("SELECT * FROM books WHERE origin = '${BookType.local}'")
@Query("SELECT * FROM books WHERE origin = '${BookType.local}' order by durChapterTime desc")
fun observeLocal(): DataSource.Factory<Int, Book>
@Query("SELECT * FROM books WHERE `group` = :group")
@ -42,12 +42,6 @@ interface BookDao {
@get:Query("SELECT COUNT(*) FROM books")
val allBookCount: Int
@Query("SELECT * FROM books ORDER BY durChapterTime DESC limit 0,20")
fun recentRead(): DataSource.Factory<Int, Book>
@Query("SELECT * FROM books ORDER BY durChapterTime DESC limit 0,20")
fun getRecentRead(): List<Book>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insert(vararg book: Book)
@ -56,4 +50,5 @@ interface BookDao {
@Query("delete from books where bookUrl = :bookUrl")
fun delete(bookUrl: String)
}

@ -23,7 +23,7 @@ class MainViewModel(application: Application) : BaseViewModel(application) {
fun upChapterList() {
execute {
App.db.bookDao().getRecentRead().forEach { book ->
App.db.bookDao().allBooks.forEach { book ->
if (book.origin != BookType.local) {
App.db.bookSourceDao().getBookSource(book.origin)?.let { bookSource ->
synchronized(this) {

Loading…
Cancel
Save