# ListUpdateCallback

# 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)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/recyclerview/widget/ListUpdateCallback "View this page in Java")

<br />

```
interface ListUpdateCallback
```

<br />

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

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

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

|--------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [SortedList.BatchedCallback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SortedList.BatchedCallback) | A callback implementation that can batch notify events dispatched by the SortedList.                                                                                                                                                                                                                                                                                                   |
| [SortedListAdapterCallback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SortedListAdapterCallback)   | A[SortedList.Callback](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SortedList.Callback)implementation that can bind a[SortedList](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/SortedList)to a[RecyclerView.Adapter](https://developer.android.com/reference/kotlin/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 functions                              |
|-------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onChanged](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListUpdateCallback#onChanged(int,int,java.lang.Object))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, payload: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?)` Called when`count`number of items are updated at the given position. |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onInserted](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListUpdateCallback#onInserted(int,int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when`count`number of items are inserted at the given position.                                                                                                        |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onMoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListUpdateCallback#onMoved(int,int))`(fromPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, toPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when an item changes its position in the list.                                                                                                                     |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html) | [onRemoved](https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/ListUpdateCallback#onRemoved(int,int))`(position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`, count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`)` Called when`count`number of items are removed from the given position.                                                                                                         |

## Public functions

### onChanged

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

```
fun onChanged(position: Int, count: Int, payload: Any?): Unit
```

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

|                                        Parameters                                         |
|-------------------------------------------------------------------------------------------|--------------------------------------------------|
| `position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | The position of the item which has been updated. |
| `count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)      | The number of items which has changed.           |
| `payload: `[Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`?` | The payload for the changed items.               |

### onInserted

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

```
fun onInserted(position: Int, count: Int): Unit
```

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

|                                       Parameters                                        |
|-----------------------------------------------------------------------------------------|-------------------------------------------|
| `position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The position of the new item.             |
| `count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)    | 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)  

```
fun onMoved(fromPosition: Int, toPosition: Int): Unit
```

Called when an item changes its position in the list.  

|                                         Parameters                                          |
|---------------------------------------------------------------------------------------------|----------------------------------------------------|
| `fromPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The previous position of the item before the move. |
| `toPosition: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)   | The new position of the item.                      |

### onRemoved

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

```
fun onRemoved(position: Int, count: Int): Unit
```

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

|                                       Parameters                                        |
|-----------------------------------------------------------------------------------------|--------------------------------------------------|
| `position: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html) | The position of the item which has been removed. |
| `count: `[Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)    | The number of items which have been removed.     |