From c4a6151e60238f0960bcb973372eb5979a42ab94 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 12 Sep 2022 19:35:11 +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 --- .../main/java/io/legado/app/data/dao/BookSourceDao.kt | 8 +++++++- .../io/legado/app/ui/main/explore/ExploreFragment.kt | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt index a7d25a40a..050e6afde 100644 --- a/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt +++ b/app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt @@ -98,7 +98,7 @@ interface BookSourceDao { and trim(bookSourceGroup) <> '' order by customOrder""" ) - fun flowExploreGroup(): Flow> + fun flowExploreGroupUnProcessed(): Flow> @Query("select * from book_sources where bookSourceGroup like '%' || :group || '%'") fun getByGroup(group: String): List @@ -180,4 +180,10 @@ interface BookSourceDao { dealGroups(list) } } + + fun flowExploreGroup(): Flow> { + return flowExploreGroupUnProcessed().map { list -> + dealGroups(list) + } + } } \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt index 42c374329..21b0e0b4c 100644 --- a/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt +++ b/app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt @@ -14,7 +14,6 @@ import androidx.recyclerview.widget.RecyclerView import io.legado.app.R import io.legado.app.base.VMBaseFragment import io.legado.app.constant.AppLog -import io.legado.app.constant.AppPattern import io.legado.app.data.appDb import io.legado.app.data.entities.BookSource import io.legado.app.databinding.FragmentExploreBinding @@ -23,7 +22,10 @@ import io.legado.app.lib.theme.primaryColor import io.legado.app.lib.theme.primaryTextColor import io.legado.app.ui.book.explore.ExploreShowActivity import io.legado.app.ui.book.source.edit.BookSourceEditActivity -import io.legado.app.utils.* +import io.legado.app.utils.applyTint +import io.legado.app.utils.cnCompare +import io.legado.app.utils.setEdgeEffectColor +import io.legado.app.utils.startActivity import io.legado.app.utils.viewbindingdelegate.viewBinding import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job @@ -106,9 +108,7 @@ class ExploreFragment : VMBaseFragment(R.layout.fragment_explo launch { appDb.bookSourceDao.flowExploreGroup().conflate().collect { groups.clear() - it.map { group -> - groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex)) - } + groups.addAll(it) upGroupsMenu() } }