initialisation of recycler view with room taking too much time and recycler view initialisation blocking the click on the other widgets of the view

非 Y 不嫁゛ 提交于 2020-06-29 03:39:44

问题


I'm initializing a recyclerView using a room local database but it's taking too much time. The recycler view is in a view pager and it takes a lot of time to load. It also blocks the page and avoids the user to click on the other widgets of the view while loading. Is there a way to avoid it to block the application and to make to loading faster?

cashflows.apply {
    layoutManager = LinearLayoutManager(requireContext())
    setHasFixedSize(true)
    itemsOM = mutableListOf<TransactionItem>()
    if ( viewModel.omTransactions.size>0){
        cashflows.visibility=View.VISIBLE
    } else {
        cashflows.visibility=View.GONE
        text_placeholder.text=resources.getString(R.string.no_cashflow)
    }
    // Make sure we cancel the previous job before creating a new one
    lifecycleScope.launch {
        viewModel.omTransactions.forEach {
            if (it.transaction?.transactionService != ENUMSERVICE.SOLDERESTANTORANGE) {
                itemsOM.add(TransactionItem(custumSMS = it, home = true))
            }
        }
        adapter = GroupAdapter<ViewHolder>().apply {
            add(Section(itemsOM))
        }
    }
}

来源:https://stackoverflow.com/questions/62473686/initialisation-of-recycler-view-with-room-taking-too-much-time-and-recycler-view

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!