pull/1486/head
gedoor 3 years ago
parent 818aa90ed9
commit ebfe3a972c
  1. 4
      app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt
  2. 1
      app/src/main/java/io/legado/app/ui/main/MainViewModel.kt
  3. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt
  4. 2
      app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt

@ -17,7 +17,7 @@ interface BookGroupDao {
@Query("SELECT * FROM book_groups ORDER BY `order`") @Query("SELECT * FROM book_groups ORDER BY `order`")
fun flowAll(): Flow<List<BookGroup>> fun flowAll(): Flow<List<BookGroup>>
@Query( @get:Query(
""" """
SELECT * FROM book_groups where (groupId >= 0 and show > 0) SELECT * FROM book_groups where (groupId >= 0 and show > 0)
or (groupId = -4 and show > 0 and (select count(bookUrl) from books where type != ${BookType.audio} and origin != '${BookType.local}' and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0) > 0) or (groupId = -4 and show > 0 and (select count(bookUrl) from books where type != ${BookType.audio} and origin != '${BookType.local}' and ((SELECT sum(groupId) FROM book_groups where groupId > 0) & `group`) = 0) > 0)
@ -26,7 +26,7 @@ interface BookGroupDao {
or (groupId = -1 and show > 0) or (groupId = -1 and show > 0)
ORDER BY `order`""" ORDER BY `order`"""
) )
fun flowShow(): Flow<List<BookGroup>> val show: Flow<List<BookGroup>>
@Query("SELECT * FROM book_groups where groupId >= 0 ORDER BY `order`") @Query("SELECT * FROM book_groups where groupId >= 0 ORDER BY `order`")
fun flowSelect(): Flow<List<BookGroup>> fun flowSelect(): Flow<List<BookGroup>>

@ -17,7 +17,6 @@ import io.legado.app.model.CacheBook
import io.legado.app.model.webBook.WebBook import io.legado.app.model.webBook.WebBook
import io.legado.app.service.CacheBookService import io.legado.app.service.CacheBookService
import io.legado.app.utils.postEvent import io.legado.app.utils.postEvent
import kotlinx.coroutines.* import kotlinx.coroutines.*
import timber.log.Timber import timber.log.Timber
import java.util.concurrent.CopyOnWriteArraySet import java.util.concurrent.CopyOnWriteArraySet

@ -76,7 +76,7 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf),
private fun initBookGroupData() { private fun initBookGroupData() {
groupsFlowJob?.cancel() groupsFlowJob?.cancel()
groupsFlowJob = launch { groupsFlowJob = launch {
appDb.bookGroupDao.flowShow().collect { appDb.bookGroupDao.show.collect {
upGroup(it) upGroup(it)
} }
} }

@ -100,7 +100,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
private fun initGroupData() { private fun initGroupData() {
groupsFlowJob?.cancel() groupsFlowJob?.cancel()
groupsFlowJob = launch { groupsFlowJob = launch {
appDb.bookGroupDao.flowShow().collect { appDb.bookGroupDao.show.collect {
if (it != bookGroups) { if (it != bookGroups) {
bookGroups = it bookGroups = it
booksAdapter.notifyDataSetChanged() booksAdapter.notifyDataSetChanged()

Loading…
Cancel
Save