ItemCallback

abstract class ItemCallback<T>(source)

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

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.

Parameters

<T>

Type of items to compare.

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
abstract fun areContentsTheSame(@NonNull oldItem: T, @NonNull newItem: T): Boolean
Called to check whether two items have the same data.
Link copied to clipboard
abstract fun areItemsTheSame(@NonNull oldItem: T, @NonNull newItem: T): Boolean
Called to check whether two objects represent the same item.
Link copied to clipboard
open fun getChangePayload(@NonNull oldItem: T, @NonNull newItem: T): Any
When areItemsTheSame returns true for two items and areContentsTheSame returns false for them, this method is called to get a payload about the change.