This is a recyclerview diffutil and notifydatasetchanged usage comparison tutorial.
There are two main ways of providing updates to a recyclerview after a datasource changes. The classic and older way is to use a method called NotifyDataSetChanged() defined in the RecyclerView.Adapter class. However since android API 24.2, DiffUtil has been the better approach. It's more efficient as it can can calculate the difference between two lists and output a list of update operations that converts the first list into the second one.
SOURCE CODE REFERENCE : [ Ссылка ]
According to android developers site documentation, DiffUtil uses Eugene W. Myers's difference algorithm to calculate the minimal number of updates to convert one list into another. Myers's algorithm does not handle items that are moved so DiffUtil runs a second pass on the result to detect items that were moved.
TOOLS:
Language: Kotlin
IDE : Android Studio
Let's start the tutorial.
Ещё видео!