Yanneck Reiß
May 20, 2021

--

I don't know if I maybe get your question wrong, but the point of using the presented approach within this article is to avoid a costly update of all items in your adapter list.

I assume with "original solution" you refer to the adapter.notifyDataSetChanged method. The problem with this function is that if you refresh your data and all the content stays the same, the adapter will re-render all items in your RecyclerView anyways. Depending on your ViewHolder implementation and the item list size, it can have a huge performance impact.

By using the DiffUtil.ItemCallback approach, you can fine-grained determine which items in your list really contain new data to be displayed. By implementing the presented functions you can dynamically decide what item updates are important to be displayed and the RecyclerView.Adapter / ListAdapter then only needs to re-render these items.

--

--

Yanneck Reiß
Yanneck Reiß

Written by Yanneck Reiß

Follow me on my journey as a professional mobile and fullstack developer

No responses yet