pull/2274/head
kunfei 2 years ago
parent 53a0e9f1f8
commit c4a6151e60
  1. 8
      app/src/main/java/io/legado/app/data/dao/BookSourceDao.kt
  2. 10
      app/src/main/java/io/legado/app/ui/main/explore/ExploreFragment.kt

@ -98,7 +98,7 @@ interface BookSourceDao {
and trim(bookSourceGroup) <> '' and trim(bookSourceGroup) <> ''
order by customOrder""" order by customOrder"""
) )
fun flowExploreGroup(): Flow<List<String>> fun flowExploreGroupUnProcessed(): Flow<List<String>>
@Query("select * from book_sources where bookSourceGroup like '%' || :group || '%'") @Query("select * from book_sources where bookSourceGroup like '%' || :group || '%'")
fun getByGroup(group: String): List<BookSource> fun getByGroup(group: String): List<BookSource>
@ -180,4 +180,10 @@ interface BookSourceDao {
dealGroups(list) dealGroups(list)
} }
} }
fun flowExploreGroup(): Flow<List<String>> {
return flowExploreGroupUnProcessed().map { list ->
dealGroups(list)
}
}
} }

@ -14,7 +14,6 @@ import androidx.recyclerview.widget.RecyclerView
import io.legado.app.R import io.legado.app.R
import io.legado.app.base.VMBaseFragment import io.legado.app.base.VMBaseFragment
import io.legado.app.constant.AppLog import io.legado.app.constant.AppLog
import io.legado.app.constant.AppPattern
import io.legado.app.data.appDb import io.legado.app.data.appDb
import io.legado.app.data.entities.BookSource import io.legado.app.data.entities.BookSource
import io.legado.app.databinding.FragmentExploreBinding 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.lib.theme.primaryTextColor
import io.legado.app.ui.book.explore.ExploreShowActivity import io.legado.app.ui.book.explore.ExploreShowActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity 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 io.legado.app.utils.viewbindingdelegate.viewBinding
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@ -106,9 +108,7 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
launch { launch {
appDb.bookSourceDao.flowExploreGroup().conflate().collect { appDb.bookSourceDao.flowExploreGroup().conflate().collect {
groups.clear() groups.clear()
it.map { group -> groups.addAll(it)
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
}
upGroupsMenu() upGroupsMenu()
} }
} }

Loading…
Cancel
Save