# BatchingListUpdateCallback

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  
belongs to Maven artifact com.android.support:recyclerview-v7:28.0.0-alpha1  
Summary:[Ctors](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#pubctors)\|[Methods](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#)  

# BatchingListUpdateCallback

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


class
BatchingListUpdateCallback
`  
`

extends Object


``


implements

`[ListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback)`


`

|---|----------------------------------------------------|
| java.lang.Object                                      ||
| ↳ | android.support.v7.util.BatchingListUpdateCallback |

<br />

*** ** * ** ***

Wraps a[ListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback)callback and batches operations that can be merged.

For instance, when 2 add operations comes that adds 2 consecutive elements, BatchingListUpdateCallback merges them and calls the wrapped callback only once.

This is a general purpose class and is also used by[DiffResult](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult)and[SortedList](https://developer.android.com/reference/android/support/v7/util/SortedList)to minimize the number of updates that are dispatched.

If you use this class to batch updates, you must call[dispatchLastEvent()](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#dispatchLastEvent())when the stream of update events drain.

## Summary

|                                                                                                                                                    ### Public constructors                                                                                                                                                    ||
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[BatchingListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#BatchingListUpdateCallback(android.support.v7.util.ListUpdateCallback))`(`[ListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback)` callback) ` |

|                                                                                                                             ### Public methods                                                                                                                             ||
|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` void` | ` `[dispatchLastEvent](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#dispatchLastEvent())`() ` BatchingListUpdateCallback holds onto the last event to see if it can be merged with the next one.                    |
| ` void` | ` `[onChanged](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#onChanged(int, int, java.lang.Object))`(int position, int count, Object payload) ` Called when`count`number of items are updated at the given position. |
| ` void` | ` `[onInserted](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#onInserted(int, int))`(int position, int count) ` Called when`count`number of items are inserted at the given position.                                |
| ` void` | ` `[onMoved](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#onMoved(int, int))`(int fromPosition, int toPosition) ` Called when an item changes its position in the list.                                             |
| ` void` | ` `[onRemoved](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#onRemoved(int, int))`(int position, int count) ` Called when`count`number of items are removed from the given position.                                 |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#)From class` java.lang.Object ` |-------------------|-------------------------------| | ` Object`         | ` clone() `                   | | ` boolean`        | ` equals(Object arg0) `       | | ` void`           | ` finalize() `                | | ` final Class<?>` | ` getClass() `                | | ` int`            | ` hashCode() `                | | ` final void`     | ` notify() `                  | | ` final void`     | ` notifyAll() `               | | ` String`         | ` toString() `                | | ` final void`     | ` wait(long arg0, int arg1) ` | | ` final void`     | ` wait(long arg0) `           | | ` final void`     | ` wait() `                    | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback#)From interface` `[android.support.v7.util.ListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback)` ` |------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` abstract void` | ` `[onChanged](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback#onChanged(int, int, java.lang.Object))`(int position, int count, Object payload) ` Called when`count`number of items are updated at the given position. | | ` abstract void` | ` `[onInserted](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback#onInserted(int, int))`(int position, int count) ` Called when`count`number of items are inserted at the given position.                                | | ` abstract void` | ` `[onMoved](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback#onMoved(int, int))`(int fromPosition, int toPosition) ` Called when an item changes its position in the list.                                             | | ` abstract void` | ` `[onRemoved](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback#onRemoved(int, int))`(int position, int count) ` Called when`count`number of items are removed from the given position.                                 | ||

## Public constructors

### BatchingListUpdateCallback

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
BatchingListUpdateCallback (ListUpdateCallback callback)
```

<br />

<br />

|               Parameters                ||
|------------|-----------------------------|
| `callback` | `ListUpdateCallback` <br /> |

## Public methods

### dispatchLastEvent

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void dispatchLastEvent ()
```

BatchingListUpdateCallback holds onto the last event to see if it can be merged with the next one. When stream of events finish, you should call this method to dispatch the last event.

<br />

### onChanged

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

```
void onChanged (int position, 
                int count, 
                Object payload)
```

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

<br />

|                                 Parameters                                 ||
|------------|----------------------------------------------------------------|
| `position` | `int`: The position of the item which has been updated. <br /> |
| `count`    | `int`: The number of items which has changed. <br />           |
| `payload`  | `Object` <br />                                                |

### onInserted

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

|                             Parameters                              ||
|------------|---------------------------------------------------------|
| `position` | `int`: The position of the new item. <br />             |
| `count`    | `int`: The number of items that have been added. <br /> |

### onMoved

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

Called when an item changes its position in the list.

<br />

|                                    Parameters                                    ||
|----------------|------------------------------------------------------------------|
| `fromPosition` | `int`: The previous position of the item before the move. <br /> |
| `toPosition`   | `int`: The new position of the item. <br />                      |

### onRemoved

added in[version 25.1.0](https://developer.android.com/topic/libraries/support-library/revisions)  

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

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

<br />

|                                 Parameters                                 ||
|------------|----------------------------------------------------------------|
| `position` | `int`: The position of the item which has been removed. <br /> |
| `count`    | `int`: The number of items which have been removed. <br />     |

-

  ## Interfaces

  - [ListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/ListUpdateCallback)
-

  ## Classes

  - [AdapterListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/AdapterListUpdateCallback)
  - [AsyncListUtil](https://developer.android.com/reference/android/support/v7/util/AsyncListUtil)
  - [AsyncListUtil.DataCallback](https://developer.android.com/reference/android/support/v7/util/AsyncListUtil.DataCallback)
  - [AsyncListUtil.ViewCallback](https://developer.android.com/reference/android/support/v7/util/AsyncListUtil.ViewCallback)
  - [BatchingListUpdateCallback](https://developer.android.com/reference/android/support/v7/util/BatchingListUpdateCallback)
  - [DiffUtil](https://developer.android.com/reference/android/support/v7/util/DiffUtil)
  - [DiffUtil.Callback](https://developer.android.com/reference/android/support/v7/util/DiffUtil.Callback)
  - [DiffUtil.DiffResult](https://developer.android.com/reference/android/support/v7/util/DiffUtil.DiffResult)
  - [DiffUtil.ItemCallback](https://developer.android.com/reference/android/support/v7/util/DiffUtil.ItemCallback)
  - [SortedList](https://developer.android.com/reference/android/support/v7/util/SortedList)
  - [SortedList.BatchedCallback](https://developer.android.com/reference/android/support/v7/util/SortedList.BatchedCallback)
  - [SortedList.Callback](https://developer.android.com/reference/android/support/v7/util/SortedList.Callback)