DiffUtil.ItemCallback

public static abstract class DiffUtil.ItemCallback
extends Object

java.lang.Object
   ↳ androidx.recyclerview.widget.DiffUtil.ItemCallback<T>


Callback for calculating the diff between two non-null items in a list.

DiffUtil.Callback serves two roles - list indexing, and item diffing. ItemCallback handles just the second of these, which allows separation of code that indexes into an array or List from the presentation-layer and content specific diffing code.

Summary

Public constructors

ItemCallback()

Public methods

abstract boolean areContentsTheSame(T oldItem, T newItem)

Called to check whether two items have the same data.

abstract boolean areItemsTheSame(T oldItem, T newItem)

Called to check whether two objects represent the same item.

Object getChangePayload(T oldItem, T newItem)

When areItemsTheSame(T, T) returns true for two items and areContentsTheSame(T, T) returns false for them, this method is called to get a payload about the change.

Inherited methods

Public constructors

ItemCallback

public ItemCallback ()

Public methods

areContentsTheSame

public abstract boolean areContentsTheSame (T oldItem, 
                T newItem)

Called to check whether two items have the same data.

This information is used to detect if the contents of an item have changed.

This method to check equality instead of