# ListUpdateCallback

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

*** ** * ** ***


```
public interface ListUpdateCallback
```

<br />

Known direct subclasses [AdapterListUpdateCallback](https://developer.android.com/reference/androidx/recyclerview/widget/AdapterListUpdateCallback), [BatchingListUpdateCallback](https://developer.android.com/reference/androidx/recyclerview/widget/BatchingListUpdateCallback), [SortedList.Callback](https://developer.android.com/reference/androidx/recyclerview/widget/SortedList.Callback)

|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/AdapterListUpdateCallback` | ListUpdateCallback that dispatches update events to the given adapter. |
| `https://developer.android.com/reference/androidx/recyclerview/widget/BatchingListUpdateCallback` | Wraps a `https://developer.android.com/reference/androidx/recyclerview/widget/ListUpdateCallback` callback and batches operations that can be merged. |
| `https://developer.android.com/reference/androidx/recyclerview/widget/SortedList.Callback` | The class that controls the behavior of the `https://developer.android.com/reference/androidx/recyclerview/widget/SortedList`. |

Known indirect subclasses [SortedList.BatchedCallback](https://developer.android.com/reference/androidx/recyclerview/widget/SortedList.BatchedCallback), [SortedListAdapterCallback](https://developer.android.com/reference/androidx/recyclerview/widget/SortedListAdapterCallback)

|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/SortedList.BatchedCallback` | A callback implementation that can batch notify events dispatched by the SortedList. |
| `https://developer.android.com/reference/androidx/recyclerview/widget/SortedListAdapterCallback` | A `https://developer.android.com/reference/androidx/recyclerview/widget/SortedList.Callback` implementation that can bind a `https://developer.android.com/reference/androidx/recyclerview/widget/SortedList` to a `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter`. |

*** ** * ** ***

An interface that can receive Update operations that are applied to a list.

This class can be used together with DiffUtil to detect changes between two lists.

## Summary

| ### Public methods |
|---|---|
| `abstract void` | `https://developer.android.com/reference/androidx/recyclerview/widget/ListUpdateCallback#onChanged(int,int,java.lang.Object)(int position, int count, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html payload)` Called when `count` number of items are updated at the given position. |
| `abstract void` | `https://developer.android.com/reference/androidx/recyclerview/widget/ListUpdateCallback#onInserted(int,int)(int position, int count)` Called when `count` number of items are inserted at the given position. |
| `abstract void` | `https://developer.android.com/reference/androidx/recyclerview/widget/ListUpdateCallback#onMoved(int,int)(int fromPosition, int toPosition)` Called when an item changes its position in the list. |
| `abstract void` | `https://developer.android.com/reference/androidx/recyclerview/widget/ListUpdateCallback#onRemoved(int,int)(int position, int count)` Called when `count` number of items are removed from the given position. |

## Public methods

### onChanged

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

```
abstract void onChanged(int position, int count, @Nullable Object payload)
```

Called when `count` number of items are updated at the given position.

| Parameters |
|---|---|
| `int position` | The position of the item which has been updated. |
| `int count` | The number of items which has changed. |
| `@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html payload` | The payload for the changed items. |

### onInserted

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

```
abstract void onInserted(int position, int count)
```

Called when `count` number of items are inserted at the given position.

| Parameters |
|---|---|
| `int position` | The position of the new item. |
| `int count` | The number of items that have been added. |

### onMoved

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

```
abstract void onMoved(int fromPosition, int toPosition)
```

Called when an item changes its position in the list.

| Parameters |
|---|---|
| `int fromPosition` | The previous position of the item before the move. |
| `int toPosition` | The new position of the item. |

### onRemoved

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

```
abstract void onRemoved(int position, int count)
```

Called when `count` number of items are removed from the given position.

| Parameters |
|---|---|
| `int position` | The position of the item which has been removed. |
| `int count` | The number of items which have been removed. |