# DiffCallback

Artifact: [androidx.leanback:leanback](https://developer.android.com/jetpack/androidx/releases/leanback) [View Source](https://cs.android.com/search?q=file:androidx/leanback/widget/DiffCallback.java+class:androidx.leanback.widget.DiffCallback) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***


```
public abstract class DiffCallback<Value>
```

<br />

Known direct subclasses [GuidedActionDiffCallback](https://developer.android.com/reference/androidx/leanback/widget/GuidedActionDiffCallback)

|---|---|
| `https://developer.android.com/reference/androidx/leanback/widget/GuidedActionDiffCallback` | DiffCallback used for GuidedActions, see `https://developer.android.com/reference/androidx/leanback/app/GuidedStepSupportFragment#setActionsDiffCallback(androidx.leanback.widget.DiffCallback<androidx.leanback.widget.GuidedAction>)`. |

*** ** * ** ***

Callback that informs `https://developer.android.com/reference/androidx/leanback/widget/ArrayObjectAdapter` how to compute list updates when using `https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil` in `https://developer.android.com/reference/androidx/leanback/widget/ArrayObjectAdapter#setItems(java.util.List,androidx.leanback.widget.DiffCallback)` method.

The `https://developer.android.com/reference/androidx/leanback/widget/ArrayObjectAdapter#setItems(java.util.List,androidx.leanback.widget.DiffCallback)` method will pass items from different lists to this callback in order to implement the `https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil.Callback` it uses to compute differences between lists.

| Parameters |
|---|---|
| `<Value>` | Type of items to compare. |

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/leanback/widget/DiffCallback#DiffCallback()()` |

| ### Public methods |
|---|---|
| `abstract boolean` | `https://developer.android.com/reference/androidx/leanback/widget/DiffCallback#areContentsTheSame(Value,Value)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value oldItem, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value newItem)` Called to decide whether two items have the same data. |
| `abstract boolean` | `https://developer.android.com/reference/androidx/leanback/widget/DiffCallback#areItemsTheSame(Value,Value)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value oldItem, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value newItem)` Called to decide whether two objects represent the same item. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/java/lang/Object.html` | `https://developer.android.com/reference/androidx/leanback/widget/DiffCallback#getChangePayload(Value,Value)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value oldItem, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value newItem)` Called to get a change payload between an old and new version of an item. |

## Public constructors

### DiffCallback

Added in 1.1.0

```
public DiffCallback()
```

## Public methods

### areContentsTheSame

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public abstract boolean areContentsTheSame(@NonNull Value oldItem, @NonNull 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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value oldItem` | The item in the old list. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value newItem` | The item in the new list. |

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

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil.Callback#areContentsTheSame(int,int)` |   |

### areItemsTheSame

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public abstract boolean areItemsTheSame(@NonNull Value oldItem, @NonNull Value newItem)
```

Called to decide whether two objects represent the same item.

| Parameters |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value oldItem` | The item in the old list. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html Value newItem` | The item in the new list. |

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

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil.Callback#areItemsTheSame(int,int)` |   |

### getChangePayload

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
public @Nullable Object getChangePayload(@NonNull Value oldItem, @NonNull Value newItem)
```

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

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil.Callback#getChangePayload(int,int)` |   |