I’ve two recyclerview and need to share the same PagingDataFlow into both, so they can display the same data ( some horizontal scrolling issue, so some data will be on left some will be on the right)
lifecycleScope.launch {
val pagingDataFlow =
viewModel.getBusinessvRecords(recordSearchRequest)
try {
lifecycleScope.launch {
pagingDataFlow.collectLatest { pagingData ->
binding.recyclerViewLeft.post {
pagingAdapterLeft.submitData(lifecycle, pagingData)
}
}
}
lifecycleScope.launch {
pagingDataFlow.collectLatest { pagingData ->
binding.recyclerViewRight.post {
pagingAdapterRight.submitData(lifecycle, pagingData)
}
}
}
} catch (e: Exception) {
Timber.tag("Exception ").e("$e")
}
}
I’m getting crush, as
java.lang.IllegalStateException: Cannot call this method while RecyclerView is computing a layout or scrolling androidx.recyclerview.widget.RecyclerView{b2ae6b VFED..... ......I. 0,75-220,97 #7f0a0546 app:id/recyclerViewLeft}, adapter:androidx.recyclerview.widget.ConcatAdapter@8ab89d8, layout:androidx.recyclerview.widget.LinearLayoutManager@efb0dc8, context:dagger.hilt.android.internal.managers.ViewComponentManager$FragmentContextWrapper@ca861d7
Is there a solution to my problem that doesn’t crush for Android 29+ versions?
5