The Android Developer Challenge is back! Submit your idea before December 2.

DiffCallback

abstract class DiffCallback<Value : Any!>
kotlin.Any
   ↳ androidx.leanback.widget.DiffCallback

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

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

Public methods

abstract Boolean
areContentsTheSame(@NonNull oldItem: Value, @NonNull newItem: Value)

Called to decide whether two items have the same data.

abstract Boolean
areItemsTheSame(@NonNull oldItem: Value, @NonNull newItem: Value)

Called to decide whether two objects represent the same item.

open Any!
getChangePayload(@NonNull oldItem: Value, @NonNull newItem: Value)

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

Public constructors

<init>

DiffCallback()

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.

Public methods

areContentsTheSame

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

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.
Return
Boolean: True if the contents of the items are the same or false if they are different.

areItemsTheSame

abstract fun areItemsTheSame(@NonNull oldItem: Value, @NonNull newItem: Value): Boolean

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.
Return
Boolean: True if the two items represent the same object or false if they are different.

getChangePayload

open fun getChangePayload(@NonNull oldItem: Value, @NonNull newItem: Value): Any!

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