未分组排除本地和音频

pull/433/head
gedoor 4 years ago
parent 7a6ec940f7
commit 7f45efed00
  1. 16
      app/src/main/java/io/legado/app/data/dao/BookDao.kt
  2. 17
      app/src/main/java/io/legado/app/data/entities/BookGroup.kt

@ -18,18 +18,22 @@ interface BookDao {
@Query("SELECT * FROM books WHERE origin = '${BookType.local}'")
fun observeLocal(): LiveData<List<Book>>
@Query(
"""
select * from books where ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0 and type != ${BookType.audio} and origin != '${BookType.local}'
"""
)
fun observeNoGroup(): LiveData<List<Book>>
@Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups where groupId > 0) & `group` = 0")
fun observeNoGroupSize(): LiveData<Int>
@Query("SELECT bookUrl FROM books WHERE origin = '${BookType.local}'")
fun observeLocalUri(): LiveData<List<String>>
@Query("SELECT * FROM books WHERE (`group` & :group) > 0")
fun observeByGroup(group: Long): LiveData<List<Book>>
@Query("select * from books where (SELECT sum(groupId) FROM book_groups where groupId > 0) & `group` = 0")
fun observeNoGroup(): LiveData<List<Book>>
@Query("select count(bookUrl) from books where (SELECT sum(groupId) FROM book_groups where groupId > 0) & `group` = 0")
fun observeNoGroupSize(): LiveData<Int>
@Query("SELECT * FROM books WHERE name like '%'||:key||'%' or author like '%'||:key||'%'")
fun liveDataSearch(key: String): LiveData<List<Book>>

@ -1,8 +1,11 @@
package io.legado.app.data.entities
import android.content.Context
import android.os.Parcelable
import androidx.room.Entity
import androidx.room.PrimaryKey
import io.legado.app.R
import io.legado.app.constant.AppConst
import kotlinx.android.parcel.Parcelize
@Parcelize
@ -13,4 +16,16 @@ data class BookGroup(
var groupName: String,
var order: Int = 0,
var show: Boolean = true
) : Parcelable
) : Parcelable {
fun getDefaultName(context: Context): String {
return when (groupId) {
AppConst.bookGroupAllId -> context.getString(R.string.all)
AppConst.bookGroupAudioId -> context.getString(R.string.audio)
AppConst.bookGroupLocalId -> context.getString(R.string.local)
AppConst.bookGroupNoneId -> context.getString(R.string.no_group)
else -> groupName
}
}
}
Loading…
Cancel
Save