优化
This commit is contained in:
@@ -31,6 +31,8 @@ import io.legado.app.utils.showDialogFragment
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -110,7 +112,7 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun initGroupData() {
|
||||
launch {
|
||||
appDb.bookGroupDao.flowAll().collect {
|
||||
appDb.bookGroupDao.flowAll().conflate().collect {
|
||||
groupList.clear()
|
||||
groupList.addAll(it)
|
||||
adapter.notifyDataSetChanged()
|
||||
@@ -128,15 +130,16 @@ class ArrangeBookActivity : VMBaseActivity<ActivityArrangeBookBinding, ArrangeBo
|
||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||
AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup()
|
||||
else -> appDb.bookDao.flowByGroup(groupId)
|
||||
}.collect { list ->
|
||||
val books = when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||
1 -> list.sortedByDescending { it.latestChapterTime }
|
||||
2 -> list.sortedWith { o1, o2 ->
|
||||
}.conflate().map { books ->
|
||||
when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||
1 -> books.sortedByDescending { it.latestChapterTime }
|
||||
2 -> books.sortedWith { o1, o2 ->
|
||||
o1.name.cnCompare(o2.name)
|
||||
}
|
||||
3 -> list.sortedBy { it.order }
|
||||
else -> list.sortedByDescending { it.durChapterTime }
|
||||
3 -> books.sortedBy { it.order }
|
||||
else -> books.sortedByDescending { it.durChapterTime }
|
||||
}
|
||||
}.conflate().collect { books ->
|
||||
adapter.setItems(books)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.flow.map
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -156,11 +158,11 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
||||
AppConst.bookGroupAudioId -> appDb.bookDao.flowAudio()
|
||||
AppConst.bookGroupNoneId -> appDb.bookDao.flowNoGroup()
|
||||
else -> appDb.bookDao.flowByGroup(groupId)
|
||||
}.collect { list ->
|
||||
val booksDownload = list.filter {
|
||||
}.conflate().map { books ->
|
||||
val booksDownload = books.filter {
|
||||
it.type == 0
|
||||
}
|
||||
val books = when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||
when (getPrefInt(PreferKey.bookshelfSort)) {
|
||||
1 -> booksDownload.sortedByDescending { it.latestChapterTime }
|
||||
2 -> booksDownload.sortedWith { o1, o2 ->
|
||||
o1.name.cnCompare(o2.name)
|
||||
@@ -168,6 +170,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
||||
3 -> booksDownload.sortedBy { it.order }
|
||||
else -> booksDownload.sortedByDescending { it.durChapterTime }
|
||||
}
|
||||
}.conflate().collect { books ->
|
||||
adapter.setItems(books)
|
||||
initCacheSize(books)
|
||||
}
|
||||
@@ -177,7 +180,7 @@ class CacheActivity : VMBaseActivity<ActivityCacheBookBinding, CacheViewModel>()
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private fun initGroupData() {
|
||||
launch {
|
||||
appDb.bookGroupDao.flowAll().collect {
|
||||
appDb.bookGroupDao.flowAll().conflate().collect {
|
||||
groupList.clear()
|
||||
groupList.addAll(it)
|
||||
adapter.notifyDataSetChanged()
|
||||
|
||||
@@ -67,12 +67,10 @@ class ChangeCoverDialog() : BaseDialogFragment(R.layout.dialog_change_cover),
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
viewModel.dataFlow
|
||||
.conflate()
|
||||
.collect {
|
||||
adapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
viewModel.dataFlow.conflate().collect {
|
||||
adapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -145,15 +145,13 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
launch {
|
||||
viewModel.searchDataFlow
|
||||
.conflate()
|
||||
.collect {
|
||||
adapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
viewModel.searchDataFlow.conflate().collect {
|
||||
adapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
launch {
|
||||
appDb.bookSourceDao.flowGroupEnabled().collect {
|
||||
appDb.bookSourceDao.flowGroupEnabled().conflate().collect {
|
||||
groups.clear()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
|
||||
@@ -177,15 +177,13 @@ class ChangeChapterSourceDialog() : BaseDialogFragment(R.layout.dialog_chapter_c
|
||||
binding.toolBar.menu.applyTint(requireContext())
|
||||
}
|
||||
launch {
|
||||
viewModel.searchDataFlow
|
||||
.conflate()
|
||||
.collect {
|
||||
searchBookAdapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
viewModel.searchDataFlow.conflate().collect {
|
||||
searchBookAdapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
launch {
|
||||
appDb.bookSourceDao.flowGroupEnabled().collect {
|
||||
appDb.bookSourceDao.flowGroupEnabled().conflate().collect {
|
||||
groups.clear()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
|
||||
@@ -28,6 +28,7 @@ import io.legado.app.utils.setLayout
|
||||
import io.legado.app.utils.showDialogFragment
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import io.legado.app.utils.visible
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@@ -67,7 +68,7 @@ class GroupManageDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.bookGroupDao.flowAll().collect {
|
||||
appDb.bookGroupDao.flowAll().conflate().collect {
|
||||
adapter.setItems(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.legado.app.utils.applyTint
|
||||
import io.legado.app.utils.setLayout
|
||||
import io.legado.app.utils.showDialogFragment
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@@ -86,7 +87,7 @@ class GroupSelectDialog() : BaseDialogFragment(R.layout.dialog_book_group_picker
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.bookGroupDao.flowSelect().collect {
|
||||
appDb.bookGroupDao.flowSelect().conflate().collect {
|
||||
adapter.setItems(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.Dispatchers.Main
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.io.File
|
||||
@@ -121,7 +122,7 @@ class ImportBookActivity : VMBaseActivity<ActivityImportBookBinding, ImportBookV
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.bookDao.flowLocalUri().collect {
|
||||
appDb.bookDao.flowLocalUri().conflate().collect {
|
||||
adapter.upBookHas(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.legado.app.utils.setEdgeEffectColor
|
||||
import io.legado.app.utils.snackbar
|
||||
import io.legado.app.utils.splitNotBlank
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleViewModel>(),
|
||||
@@ -66,7 +67,7 @@ class TxtTocRuleActivity : VMBaseActivity<ActivityTxtTocRuleBinding, TxtTocRuleV
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.txtTocRuleDao.observeAll().collect { tocRules ->
|
||||
appDb.txtTocRuleDao.observeAll().conflate().collect { tocRules ->
|
||||
adapter.setItems(tocRules)
|
||||
upCountView()
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import io.legado.app.ui.document.HandleFileContract
|
||||
import io.legado.app.ui.login.SourceLoginActivity
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -133,7 +134,7 @@ class SpeakEngineDialog(val callBack: CallBack) : BaseDialogFragment(R.layout.di
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.httpTTSDao.flowAll().collect {
|
||||
appDb.httpTTSDao.flowAll().conflate().collect {
|
||||
adapter.setItems(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import io.legado.app.ui.widget.recycler.VerticalDivider
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
|
||||
@@ -89,7 +90,7 @@ class TocRegexDialog() : BaseDialogFragment(R.layout.dialog_toc_regex),
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.txtTocRuleDao.observeAll().collect { tocRules ->
|
||||
appDb.txtTocRuleDao.observeAll().conflate().collect { tocRules ->
|
||||
initSelectedName(tocRules)
|
||||
adapter.setItems(tocRules)
|
||||
}
|
||||
|
||||
@@ -197,15 +197,13 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
viewModel.searchDataFlow
|
||||
.conflate()
|
||||
.collect {
|
||||
adapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
viewModel.searchDataFlow.conflate().collect {
|
||||
adapter.setItems(it)
|
||||
delay(1000)
|
||||
}
|
||||
}
|
||||
launch {
|
||||
appDb.bookSourceDao.flowGroupEnabled().collect {
|
||||
appDb.bookSourceDao.flowGroupEnabled().conflate().collect {
|
||||
groups.clear()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
@@ -287,8 +285,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
||||
binding.tvBookShow.gone()
|
||||
binding.rvBookshelfSearch.gone()
|
||||
} else {
|
||||
val bookFlow = appDb.bookDao.flowSearch(key)
|
||||
bookFlow.collect {
|
||||
appDb.bookDao.flowSearch(key).conflate().collect {
|
||||
if (it.isEmpty()) {
|
||||
binding.tvBookShow.gone()
|
||||
binding.rvBookshelfSearch.gone()
|
||||
@@ -305,7 +302,7 @@ class SearchActivity : VMBaseActivity<ActivityBookSearchBinding, SearchViewModel
|
||||
when {
|
||||
key.isNullOrBlank() -> appDb.searchKeywordDao.flowByUsage()
|
||||
else -> appDb.searchKeywordDao.flowSearch(key)
|
||||
}.collect {
|
||||
}.conflate().collect {
|
||||
historyKeyAdapter.setItems(it)
|
||||
if (it.isEmpty()) {
|
||||
binding.tvClearHistory.invisible()
|
||||
|
||||
@@ -295,14 +295,13 @@ class BookSourceActivity : VMBaseActivity<ActivityBookSourceBinding, BookSourceV
|
||||
|
||||
private fun initLiveDataGroup() {
|
||||
launch {
|
||||
appDb.bookSourceDao.flowGroup()
|
||||
.collect {
|
||||
groups.clear()
|
||||
it.forEach { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
}
|
||||
upGroupMenu()
|
||||
appDb.bookSourceDao.flowGroup().conflate().collect {
|
||||
groups.clear()
|
||||
it.forEach { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
}
|
||||
upGroupMenu()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
|
||||
}
|
||||
}.catch {
|
||||
AppLog.put("书架更新出错", it)
|
||||
}.collect { list ->
|
||||
}.conflate().collect { list ->
|
||||
binding.tvEmptyMsg.isGone = list.isNotEmpty()
|
||||
booksAdapter.setItems(list)
|
||||
delay(100)
|
||||
|
||||
@@ -140,7 +140,7 @@ class BookshelfFragment2 : BaseBookshelfFragment(R.layout.fragment_bookshelf1),
|
||||
}
|
||||
}.catch {
|
||||
AppLog.put("书架更新出错", it)
|
||||
}.collect { list ->
|
||||
}.conflate().collect { list ->
|
||||
books = list
|
||||
booksAdapter.notifyDataSetChanged()
|
||||
binding.tvEmptyMsg.isGone = getItemCount() > 0
|
||||
|
||||
@@ -28,6 +28,7 @@ import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
/**
|
||||
@@ -102,21 +103,20 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
|
||||
|
||||
private fun initGroupData() {
|
||||
launch {
|
||||
appDb.bookSourceDao.flowExploreGroup()
|
||||
.collect {
|
||||
groups.clear()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
}
|
||||
upGroupsMenu()
|
||||
appDb.bookSourceDao.flowExploreGroup().conflate().collect {
|
||||
groups.clear()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
}
|
||||
upGroupsMenu()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun upExploreData(searchKey: String? = null) {
|
||||
exploreFlowJob?.cancel()
|
||||
exploreFlowJob = launch {
|
||||
val exploreFlow = when {
|
||||
when {
|
||||
searchKey.isNullOrBlank() -> {
|
||||
appDb.bookSourceDao.flowExplore()
|
||||
}
|
||||
@@ -127,10 +127,9 @@ class ExploreFragment : VMBaseFragment<ExploreViewModel>(R.layout.fragment_explo
|
||||
else -> {
|
||||
appDb.bookSourceDao.flowExplore("%$searchKey%")
|
||||
}
|
||||
}
|
||||
exploreFlow.catch {
|
||||
}.catch {
|
||||
AppLog.put("发现界面更新数据出错", it)
|
||||
}.collect {
|
||||
}.conflate().collect {
|
||||
binding.tvEmptyMsg.isGone = it.isNotEmpty() || searchView.query.isNotEmpty()
|
||||
adapter.setItems(it, diffItemCallBack)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.flow.catch
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@@ -121,7 +122,7 @@ class RssFragment : VMBaseFragment<RssSourceViewModel>(R.layout.fragment_rss),
|
||||
private fun initGroupData() {
|
||||
groupsFlowJob?.cancel()
|
||||
groupsFlowJob = launch {
|
||||
appDb.rssSourceDao.flowGroup().collect {
|
||||
appDb.rssSourceDao.flowGroup().conflate().collect {
|
||||
groups.clear()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.legado.app.utils.requestInputMethod
|
||||
import io.legado.app.utils.setLayout
|
||||
import io.legado.app.utils.splitNotBlank
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@@ -61,7 +62,7 @@ class GroupManageDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.replaceRuleDao.flowGroup().collect {
|
||||
appDb.replaceRuleDao.flowGroup().conflate().collect {
|
||||
val groups = linkedSetOf<String>()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
|
||||
@@ -194,9 +194,9 @@ class ReplaceRuleActivity : VMBaseActivity<ActivityReplaceRuleBinding, ReplaceRu
|
||||
else -> {
|
||||
appDb.replaceRuleDao.flowSearch("%$searchKey%")
|
||||
}
|
||||
}.conflate().catch {
|
||||
}.catch {
|
||||
AppLog.put("替换规则管理界面更新数据出错", it)
|
||||
}.collect {
|
||||
}.conflate().collect {
|
||||
if (dataInit) {
|
||||
setResult(Activity.RESULT_OK)
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.legado.app.ui.rss.read.ReadRssActivity
|
||||
import io.legado.app.ui.widget.recycler.VerticalDivider
|
||||
import io.legado.app.utils.startActivity
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@@ -34,7 +35,7 @@ class RssFavoritesActivity : BaseActivity<ActivityRssFavoritesBinding>(),
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.rssStarDao.liveAll().collect {
|
||||
appDb.rssStarDao.liveAll().conflate().collect {
|
||||
adapter.setItems(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import io.legado.app.lib.theme.primaryColor
|
||||
import io.legado.app.ui.widget.recycler.VerticalDivider
|
||||
import io.legado.app.utils.*
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
|
||||
@@ -59,7 +60,7 @@ class GroupManageDialog : BaseDialogFragment(R.layout.dialog_recycler_view),
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.rssSourceDao.flowGroup().collect {
|
||||
appDb.rssSourceDao.flowGroup().conflate().collect {
|
||||
val groups = linkedSetOf<String>()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
|
||||
@@ -191,7 +191,7 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
|
||||
|
||||
private fun initGroupFlow() {
|
||||
launch {
|
||||
appDb.rssSourceDao.flowGroup().collect {
|
||||
appDb.rssSourceDao.flowGroup().conflate().collect {
|
||||
groups.clear()
|
||||
it.map { group ->
|
||||
groups.addAll(group.splitNotBlank(AppPattern.splitGroupRegex))
|
||||
@@ -247,9 +247,9 @@ class RssSourceActivity : VMBaseActivity<ActivityRssSourceBinding, RssSourceView
|
||||
else -> {
|
||||
appDb.rssSourceDao.flowSearch("%$searchKey%")
|
||||
}
|
||||
}.conflate().catch {
|
||||
}.catch {
|
||||
AppLog.put("订阅源管理界面更新数据出错", it)
|
||||
}.collect {
|
||||
}.conflate().collect {
|
||||
adapter.setItems(it, adapter.diffItemCallback)
|
||||
delay(100)
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ import io.legado.app.utils.showDialogFragment
|
||||
import io.legado.app.utils.toastOnUi
|
||||
import io.legado.app.utils.viewbindingdelegate.viewBinding
|
||||
import kotlinx.coroutines.Dispatchers.IO
|
||||
import kotlinx.coroutines.flow.conflate
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
@@ -61,7 +62,7 @@ class RuleSubActivity : BaseActivity<ActivityRuleSubBinding>(),
|
||||
|
||||
private fun initData() {
|
||||
launch {
|
||||
appDb.ruleSubDao.flowAll().collect {
|
||||
appDb.ruleSubDao.flowAll().conflate().collect {
|
||||
binding.tvEmptyMsg.isGone = it.isNotEmpty()
|
||||
adapter.setItems(it)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user