DiffUtil.Callback

public static abstract class DiffUtil.Callback
extends Object

java.lang.Object
   ↳ androidx.recyclerview.widget.DiffUtil.Callback


A Callback class used by DiffUtil while calculating the diff between two lists.

Summary

Public constructors

Callback()

Public methods

abstract boolean areContentsTheSame(int oldItemPosition, int newItemPosition)

Called by the DiffUtil when it wants to check whether two items have the same data.

abstract boolean areItemsTheSame(int oldItemPosition, int newItemPosition)

Called by the DiffUtil to decide whether two object represent the same Item.

Object getChangePayload(int oldItemPosition, int newItemPosition)

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

abstract int getNewListSize()

Returns the size of the new list.

abstract int getOldListSize()

Returns the size of the old list.

Inherited methods

Public constructors

Callback

public Callback ()

Public methods

areContentsTheSame

public abstract boolean areContentsTheSame (int oldItemPosition, 
                int newItemPosition)

Called by the DiffUtil when it wants to check whether two items have the same data. DiffUtil uses this information to detect if the contents of an item has changed.

DiffUtil uses this method to check equality instead of Object.equals(Object) so that you can change its behavior d