I have a recycler view whose adapter uses ListAdapter (version 1.1.0) :
class InnerEpisodeFragmentAdapter(
private val actCtx: Context,
) : ListAdapter<Episode, InnerEpisodeFragmentAdapter.MViewHolder>(COMPARATOR) {
...
The recycler view is fed by a kotlin flow coming from Room database Episode table :
vm.episodesFlow().asLiveData().observe(viewLifecycleOwner) { episodes ->
episodes.let { adapter.submitList(it) }
}
@Query("SELECT * FROM Episode ORDER BY pubDate DESC")
fun episodesFlow(): Flow<List<Episode>>
As excepted, each time a tuple changes in Episode table, a new list of episodes is emitted and the recycler view is update.
It works fine, but with an horrible BLINK at each update. It gives a bad user experience.
How can I avoid this blinking when the flow emit new values ?
In the previous version of my app, I used functions like notifyDataSetChanged() or notifyItemChanged() which never blink.I know I could still try to use these functions but I would be very disappointed if I could not avoid the blinks when using the kotlin flow as shown above. Thanks.