From ebfe3a972cbec6daf4d530197b40a9b87911e689 Mon Sep 17 00:00:00 2001 From: gedoor Date: Fri, 24 Dec 2021 15:12:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt | 4 ++-- app/src/main/java/io/legado/app/ui/main/MainViewModel.kt | 1 - .../legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt | 2 +- .../legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt | 2 +- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt index e33f90513..8ba1eac28 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookGroupDao.kt @@ -17,7 +17,7 @@ interface BookGroupDao { @Query("SELECT * FROM book_groups ORDER BY `order`") fun flowAll(): Flow> - @Query( + @get:Query( """ 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) @@ -26,7 +26,7 @@ interface BookGroupDao { or (groupId = -1 and show > 0) ORDER BY `order`""" ) - fun flowShow(): Flow> + val show: Flow> @Query("SELECT * FROM book_groups where groupId >= 0 ORDER BY `order`") fun flowSelect(): Flow> diff --git a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt index b98ba0c66..07ffce86d 100644 --- a/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/main/MainViewModel.kt @@ -17,7 +17,6 @@ import io.legado.app.model.CacheBook import io.legado.app.model.webBook.WebBook import io.legado.app.service.CacheBookService import io.legado.app.utils.postEvent - import kotlinx.coroutines.* import timber.log.Timber import java.util.concurrent.CopyOnWriteArraySet diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt index d5fd3eded..6228bfe9f 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style1/BookshelfFragment1.kt @@ -76,7 +76,7 @@ class BookshelfFragment1 : BaseBookshelfFragment(R.layout.fragment_bookshelf), private fun initBookGroupData() { groupsFlowJob?.cancel() groupsFlowJob = launch { - appDb.bookGroupDao.flowShow().collect { + appDb.bookGroupDao.show.collect { upGroup(it) } } diff --git a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt index 33a5110e9..8be4f327c 100644 --- a/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt +++ b/app/src/main/java/io/legado/app/ui/main/bookshelf/style2/BookshelfFragment2.kt @@ -100,7 +100,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1), private fun initGroupData() { groupsFlowJob?.cancel() groupsFlowJob = launch { - appDb.bookGroupDao.flowShow().collect { + appDb.bookGroupDao.show.collect { if (it != bookGroups) { bookGroups = it booksAdapter.notifyDataSetChanged()