pull/32/head
gedoor 6 years ago
parent 7997995936
commit ff6994b538
  1. 7
      app/src/main/java/io/legado/app/constant/BookType.kt
  2. 7
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  3. 4
      app/src/main/java/io/legado/app/data/entities/Book.kt
  4. 6
      app/src/main/java/io/legado/app/ui/bookshelf/BookshelfActivity.kt

@ -0,0 +1,7 @@
package io.legado.app.constant
object BookType {
const val default = 0
const val audio = 1
const val local = "Local"
}

@ -6,6 +6,7 @@ import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import io.legado.app.constant.BookType
import io.legado.app.data.entities.Book
@Dao
@ -14,6 +15,12 @@ interface BookDao {
@Query("SELECT * FROM books")
fun observeAll(): DataSource.Factory<Int, Book>
@Query("SELECT * FROM books WHERE type = ${BookType.audio}")
fun observeAudio(): DataSource.Factory<Int, Book>
@Query("SELECT * FROM books WHERE origin = ${BookType.local}")
fun observeLocal(): DataSource.Factory<Int, Book>
@Query("SELECT * FROM books WHERE `group` = :group")
fun observeByGroup(group: Int): DataSource.Factory<Int, Book>

@ -18,7 +18,7 @@ data class Book(
@PrimaryKey
var descUrl: String = "", // 详情页Url(本地书源存储完整文件路径)
var tocUrl: String = "", // 目录页Url (toc=table of Contents)
var origin: String = "", // 书源规则id(默认-1,表示本地书籍)
var origin: String = "", // 书源URL(默认BookType.local)
var name: String? = null, // 书籍名称(书源获取)
var customName: String? = null, // 书籍名称(用户修改)
var author: String? = null, // 作者名称(书源获取)
@ -30,7 +30,7 @@ data class Book(
var description: String? = null, // 简介内容(书源获取)
var customDescription: String? = null, // 简介内容(用户修改)
var charset: String? = null, // 自定义字符集名称(仅适用于本地书籍)
var type: Int = 0, // 0: 文本读物, 1: 有声读物
var type: Int = 0, // @BookType
var group: Int = 0, // 自定义分组索引号
var latestChapterTitle: String? = null, // 最新章节标题
var latestChapterTime: Long = 0, // 最新章节标题更新时间

@ -52,10 +52,12 @@ class BookshelfActivity : BaseActivity<BookshelfViewModel>() {
LivePagedListBuilder(App.db.bookDao().observeAll(), 10).build()
}
-2 -> {
bookshelfLiveData =
LivePagedListBuilder(App.db.bookDao().observeLocal(), 10).build()
}
-3 -> {
bookshelfLiveData =
LivePagedListBuilder(App.db.bookDao().observeAudio(), 10).build()
}
else -> {
bookshelfLiveData =

Loading…
Cancel
Save