I have a recyclerview that's been updated from remote source ,so it is working pretty well , the only annoying thing is that when the screen is pulled for a refresh and a get request is triggered the recyclerview is updated even though nothing has changed in the adapter causing the screen to blinks and that's annoying.
i tried messing with the diffutils but no result achieved
in my main fragment:
viewModel.fetchTopHeadline()
followed by an observer
topHeadline.observe(this@FeedFragment, Observer {
if(it == null) return@Observer
topHeadlineAdapter.submitList(it)
})
my Adapter:
class TopHeadlineAdapter:ListAdapter
and finally my diffutilCallback class :
class TopHeadlineDiffCallback :DiffUtil.ItemCallback<Article>(){
override fun areItemsTheSame(oldItem: Article, newItem: Article): Boolean {
return oldItem.id == newItem.id
}
override fun areContentsTheSame(oldItem: Article, newItem: Article): Boolean {
return oldItem == newItem
}
}