I am currently learning Paging 3 library. I have an app that has shimmer placeholder for showing while loading the data. When i get the data i want to hide shimmer layout and show recycler view.
lifecycleScope.launch {
quoteViewModel.getQuotes2().collectLatest {
binding.shimmerLayout.visibility = View.GONE // this line gets executed when view created and it causes shimmer layout to hide
binding.homeRecyclerView.visibility = View.VISIBLE
homeAdapter.submitData(it)
Log.d("mytag", "after submit data") // this line isn't executed
}
}
Problem here is the line after the submitData
doesn't get executed.I searched and saw the reason was because submitData
never returns so it doesn't get called. But i didn't find any example code. Can someone please show me an example code for solving this?
The logic i want to execute after submitData is to hide shimmerLayout and show recyclerView, but because that logic is before submit data, they are executed immediately, therefore shimmerLayout doesn't seem when loading data.