areContentsTheSame

abstract fun areContentsTheSame(@NonNull oldItem: T, @NonNull newItem: T): Boolean(source)

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 equals so that you can change its behavior depending on your UI.

For example, if you are using DiffUtil with a RecyclerView.Adapter, you should return whether the items' visual representations are the same.

This method is called only if areItemsTheSame returns true for these items.

Note: Two null items are assumed to represent the same contents. This callback will not be invoked for this case.

Return

True if the contents of the items are the same or false if they are different.

Parameters

oldItem

The item in the old list.

newItem

The item in the new list.

See also