Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.
added in version 1.0.0
belongs to Maven artifact androidx.leanback:leanback:1.0.0-rc01

DiffCallback

public abstract class DiffCallback
extends Object

java.lang.Object
   ↳ androidx.leanback.widget.DiffCallback<Value>


Callback that informs ArrayObjectAdapter how to compute list updates when using DiffUtil in ArrayObjectAdapter.setItems(List, DiffCallback) method.

The ArrayObjectAdapter.setItems(List, DiffCallback) method will pass items from different lists to this callback in order to implement the DiffUtil.Callback it uses to compute differences between lists.

Summary

Public constructors

DiffCallback()

Public methods

abstract boolean areContentsTheSame(Value oldItem, Value newItem)

Called to decide whether two items have the same data.

abstract boolean areItemsTheSame(Value oldItem, Value newItem)

Called to decide whether two objects represent the same item.

Object getChangePayload(Value oldItem, Value newItem)

Called to get a change payload between an old and new version of an item.

Inherited methods

Public constructors

DiffCallback

added in version 1.0.0
public DiffCallback ()

Public methods

areContentsTheSame

added in version 1.0.0
public abstract boolean areContentsTheSame (Value oldItem, 
                Value newItem)

Called to decide whether two items have the same data. This information is used to detect if the contents of an item have changed.

Parameters
oldItem Value: The item in the old list.

newItem Value: The item in the new list.

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

areItemsTheSame

added in version 1.0.0
public abstract boolean areItemsTheSame (Value oldItem, 
                Value newItem)

Called to decide whether two objects represent the same item.

Parameters
oldItem Value: The item in the old list.

newItem Value: The item in the new list.

Returns
boolean True if the two items represent the same object or false if they are different.

getChangePayload

added in version 1.0.0
public Object getChangePayload (Value oldItem, 
                Value newItem)

Called to get a change payload between an old and new version of an item.

Parameters
oldItem Value

newItem Value

Returns
Object