未分组分为网络未分组和本地未分组
This commit is contained in:
@@ -41,7 +41,8 @@ object AppConst {
|
|||||||
const val bookGroupAllId = -1L
|
const val bookGroupAllId = -1L
|
||||||
const val bookGroupLocalId = -2L
|
const val bookGroupLocalId = -2L
|
||||||
const val bookGroupAudioId = -3L
|
const val bookGroupAudioId = -3L
|
||||||
const val bookGroupNoneId = -4L
|
const val bookGroupNetNoneId = -4L
|
||||||
|
const val bookGroupLocalNoneId = -5L
|
||||||
|
|
||||||
const val notificationIdRead = -1122391
|
const val notificationIdRead = -1122391
|
||||||
const val notificationIdAudio = -1122392
|
const val notificationIdAudio = -1122392
|
||||||
|
|||||||
@@ -98,8 +98,13 @@ abstract class AppDatabase : RoomDatabase() {
|
|||||||
)
|
)
|
||||||
db.execSQL(
|
db.execSQL(
|
||||||
"""insert into book_groups(groupId, groupName, 'order', show)
|
"""insert into book_groups(groupId, groupName, 'order', show)
|
||||||
select ${AppConst.bookGroupNoneId}, '未分组', -7, 1
|
select ${AppConst.bookGroupNetNoneId}, '网络未分组', -7, 1
|
||||||
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupNoneId})"""
|
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupNetNoneId})"""
|
||||||
|
)
|
||||||
|
db.execSQL(
|
||||||
|
"""insert into book_groups(groupId, groupName, 'order', show)
|
||||||
|
select ${AppConst.bookGroupLocalNoneId}, '本地未分组', -8, 0
|
||||||
|
where not exists (select * from book_groups where groupId = ${AppConst.bookGroupLocalNoneId})"""
|
||||||
)
|
)
|
||||||
db.execSQL("update book_sources set loginUi = null where loginUi = 'null'")
|
db.execSQL("update book_sources set loginUi = null where loginUi = 'null'")
|
||||||
db.execSQL("update rssSources set loginUi = null where loginUi = 'null'")
|
db.execSQL("update rssSources set loginUi = null where loginUi = 'null'")
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ interface BookDao {
|
|||||||
select * from books where type != ${BookType.audio}
|
select * from books where type != ${BookType.audio}
|
||||||
and origin != '${BookType.local}'
|
and origin != '${BookType.local}'
|
||||||
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
||||||
and (select show from book_groups where groupId = ${AppConst.bookGroupNoneId}) != 1
|
and (select show from book_groups where groupId = ${AppConst.bookGroupNetNoneId}) != 1
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
fun flowRoot(): Flow<List<Book>>
|
fun flowRoot(): Flow<List<Book>>
|
||||||
@@ -34,7 +34,15 @@ interface BookDao {
|
|||||||
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
fun flowNoGroup(): Flow<List<Book>>
|
fun flowNetNoGroup(): Flow<List<Book>>
|
||||||
|
|
||||||
|
@Query(
|
||||||
|
"""
|
||||||
|
select * from books where type != ${BookType.audio} and origin != '${BookType.local}'
|
||||||
|
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
fun flowLocalNoGroup(): Flow<List<Book>>
|
||||||
|
|
||||||
@Query("SELECT bookUrl FROM books WHERE origin = '${BookType.local}'")
|
@Query("SELECT bookUrl FROM books WHERE origin = '${BookType.local}'")
|
||||||
fun flowLocalUri(): Flow<List<String>>
|
fun flowLocalUri(): Flow<List<String>>
|
||||||
|
|||||||
@@ -20,18 +20,27 @@ interface BookGroupDao {
|
|||||||
|
|
||||||
@get:Query(
|
@get:Query(
|
||||||
"""
|
"""
|
||||||
SELECT * FROM book_groups where (groupId >= 0 and show > 0)
|
with const as (SELECT sum(groupId) sumGroupId FROM book_groups where groupId > 0)
|
||||||
|
SELECT book_groups.* FROM book_groups, const where (groupId >= 0 and show > 0)
|
||||||
|
or (groupId = -1 and show > 0)
|
||||||
|
or (groupId = -2 and show > 0 and (select count(bookUrl) from books where origin = '${BookType.local}') > 0)
|
||||||
|
or (groupId = -3 and show > 0 and (select count(bookUrl) from books where type = ${BookType.audio}) > 0)
|
||||||
or (groupId = -4 and show > 0
|
or (groupId = -4 and show > 0
|
||||||
and (
|
and (
|
||||||
select count(bookUrl) from books
|
select count(bookUrl) from books
|
||||||
where type != '${BookType.audio}'
|
where type != '${BookType.audio}'
|
||||||
and origin != '${BookType.local}'
|
and origin != '${BookType.local}'
|
||||||
and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0
|
and const.sumGroupId & `group` = 0
|
||||||
|
) > 0
|
||||||
|
)
|
||||||
|
or (groupId = -5 and show > 0
|
||||||
|
and (
|
||||||
|
select count(bookUrl) from books
|
||||||
|
where type != '${BookType.audio}'
|
||||||
|
and origin = '${BookType.local}'
|
||||||
|
and const.sumGroupId & `group` = 0
|
||||||
) > 0
|
) > 0
|
||||||
)
|
)
|
||||||
or (groupId = -3 and show > 0 and (select count(bookUrl) from books where type = ${BookType.audio}) > 0)
|
|
||||||
or (groupId = -2 and show > 0 and (select count(bookUrl) from books where origin = '${BookType.local}') > 0)
|
|
||||||
or (groupId = -1 and show > 0)
|
|
||||||
ORDER BY `order`"""
|
ORDER BY `order`"""
|
||||||
)
|
)
|
||||||
val show: LiveData<List<BookGroup>>
|
val show: LiveData<List<BookGroup>>
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ data class BookGroup(
|
|||||||
AppConst.bookGroupAllId -> "$groupName(${context.getString(R.string.all)})"
|
AppConst.bookGroupAllId -> "$groupName(${context.getString(R.string.all)})"
|
||||||
AppConst.bookGroupAudioId -> "$groupName(${context.getString(R.string.audio)})"
|
AppConst.bookGroupAudioId -> "$groupName(${context.getString(R.string.audio)})"
|
||||||
AppConst.bookGroupLocalId -> "$groupName(${context.getString(R.string.local)})"
|
AppConst.bookGroupLocalId -> "$groupName(${context.getString(R.string.local)})"
|
||||||
AppConst.bookGroupNoneId -> "$groupName(${context.getString(R.string.no_group)})"
|
AppConst.bookGroupNetNoneId -> "$groupName(${context.getString(R.string.net_no_group)})"
|
||||||
|
AppConst.bookGroupLocalNoneId -> "$groupName(${context.getString(R.string.local_no_group)})"
|
||||||
else -> groupName
|
else -> groupName
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -159,7 +159,8 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
|||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||||
AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup()
|
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
||||||
|
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
else -> appDb.bookDao.flowByGroup(groupId)
|
||||||
}.conflate().map { books ->
|
}.conflate().map { books ->
|
||||||
val booksDownload = books.filter {
|
val booksDownload = books.filter {
|
||||||
|
|||||||
@@ -140,11 +140,12 @@ class BookshelfManageActivity :
|
|||||||
booksFlowJob?.cancel()
|
booksFlowJob?.cancel()
|
||||||
booksFlowJob = launch {
|
booksFlowJob = launch {
|
||||||
when (groupId) {
|
when (groupId) {
|
||||||
AppConst.rootGroupId -> appDb.bookDao.flowNoGroup()
|
AppConst.rootGroupId -> appDb.bookDao.flowNetNoGroup()
|
||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||||
AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup()
|
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
||||||
|
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
else -> appDb.bookDao.flowByGroup(groupId)
|
||||||
}.conflate().map { books ->
|
}.conflate().map { books ->
|
||||||
when (getPrefInt(PreferKey.bookshelfSort)) {
|
when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||||
|
|||||||
@@ -112,7 +112,8 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
|||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||||
AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup()
|
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
||||||
|
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
else -> appDb.bookDao.flowByGroup(groupId)
|
||||||
}.conflate().map { list ->
|
}.conflate().map { list ->
|
||||||
when (getPrefInt(PreferKey.bookshelfSort)) {
|
when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||||
|
|||||||
@@ -124,7 +124,8 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
|||||||
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
AppConst.bookGroupAllId -> appDb.bookDao.flowAll()
|
||||||
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
AppConst.bookGroupLocalId -> appDb.bookDao.flowLocal()
|
||||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||||
AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup()
|
AppConst.bookGroupNetNoneId -> appDb.bookDao.flowNetNoGroup()
|
||||||
|
AppConst.bookGroupLocalNoneId -> appDb.bookDao.flowLocalNoGroup()
|
||||||
else -> appDb.bookDao.flowByGroup(groupId)
|
else -> appDb.bookDao.flowByGroup(groupId)
|
||||||
}.conflate().map { list ->
|
}.conflate().map { list ->
|
||||||
when (getPrefInt(PreferKey.bookshelfSort)) {
|
when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||||
|
|||||||
@@ -1033,4 +1033,6 @@
|
|||||||
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
||||||
<string name="refresh_sort">刷新分类</string>
|
<string name="refresh_sort">刷新分类</string>
|
||||||
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
||||||
|
<string name="net_no_group">网络为分组</string>
|
||||||
|
<string name="local_no_group">本地未分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1036,4 +1036,6 @@
|
|||||||
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
||||||
<string name="refresh_sort">刷新分类</string>
|
<string name="refresh_sort">刷新分类</string>
|
||||||
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
||||||
|
<string name="net_no_group">网络为分组</string>
|
||||||
|
<string name="local_no_group">本地未分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1036,4 +1036,6 @@
|
|||||||
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
||||||
<string name="refresh_sort">刷新分类</string>
|
<string name="refresh_sort">刷新分类</string>
|
||||||
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
||||||
|
<string name="net_no_group">网络为分组</string>
|
||||||
|
<string name="local_no_group">本地未分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1033,4 +1033,6 @@
|
|||||||
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
||||||
<string name="refresh_sort">刷新分类</string>
|
<string name="refresh_sort">刷新分类</string>
|
||||||
<string name="cover_decode_js">封面解密(coverDecodeJs)</string>
|
<string name="cover_decode_js">封面解密(coverDecodeJs)</string>
|
||||||
|
<string name="net_no_group">网络为分组</string>
|
||||||
|
<string name="local_no_group">本地未分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1035,4 +1035,6 @@
|
|||||||
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
||||||
<string name="refresh_sort">刷新分类</string>
|
<string name="refresh_sort">刷新分类</string>
|
||||||
<string name="cover_decode_js">封面解密(coverDecodeJs)</string>
|
<string name="cover_decode_js">封面解密(coverDecodeJs)</string>
|
||||||
|
<string name="net_no_group">网络为分组</string>
|
||||||
|
<string name="local_no_group">本地未分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1035,4 +1035,6 @@
|
|||||||
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
||||||
<string name="refresh_sort">刷新分类</string>
|
<string name="refresh_sort">刷新分类</string>
|
||||||
<string name="cover_decode_js">封面解密(coverDecodeJs)</string>
|
<string name="cover_decode_js">封面解密(coverDecodeJs)</string>
|
||||||
|
<string name="net_no_group">网络为分组</string>
|
||||||
|
<string name="local_no_group">本地未分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -1036,4 +1036,6 @@
|
|||||||
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
<string name="ignore_audio_focus_summary">允许与其他应用同时播放音频</string>
|
||||||
<string name="refresh_sort">刷新分类</string>
|
<string name="refresh_sort">刷新分类</string>
|
||||||
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
<string name="cover_decode_js">Decode Cover Js(coverDecodeJs)</string>
|
||||||
|
<string name="net_no_group">网络为分组</string>
|
||||||
|
<string name="local_no_group">本地未分组</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
Reference in New Issue
Block a user