M - Refers to the model classpublic interface PayloadProvider<M>
| Modifier and Type | Method and Description |
|---|---|
boolean |
areContentsTheSame(M oldItem,
M newItem)
Called by the DataManager when it wants to check whether two items have the same data.
|
boolean |
areItemsTheSame(M oldItem,
M newItem)
Called by the DiffUtil to decide whether two object represent the same Item.
|
java.lang.Object |
getChangePayload(M oldItem,
M newItem)
Called by the DataManager when it wants to get the payload of changed elements.
|
boolean areContentsTheSame(M oldItem, M newItem)
DataManager uses this method to check equality instead of Object.equals(Object)
so that you can change its behavior depending on your UI.
oldItem - The item in the old listnewItem - The item in the new list which replaces the oldItemboolean areItemsTheSame(M oldItem, M newItem)
For example, if your items have unique ids, this method should check their id equality.
oldItem - The item in the old listnewItem - The item in the new list which replaces the oldItemjava.lang.Object getChangePayload(M oldItem, M newItem)
For example, if you are using DiffUtil with RecyclerView, you can return the
particular field that changed in the item and your
ItemAnimator can use that
information to run the correct animation.
null.oldItem - The item in the old listnewItem - The item in the new list