Skip to content

Most visited

Recently visited

navigation

BatchingListUpdateCallback

public class BatchingListUpdateCallback
extends Object implements ListUpdateCallback

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


Wraps a 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 and SortedList to minimize the number of updates that are dispatched.

If you use this class to batch updates, you must call dispatchLastEvent() when the stream of update events drain.

Summary

Public constructors

BatchingListUpdateCallback(ListUpdateCallback callback)

Public methods

void dispatchLastEvent()

BatchingListUpdateCallback holds onto the last event to see if it can be merged with the next one.

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

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

void onInserted(int position, int count)

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

void onMoved(int fromPosition, int toPosition)

Called when an item changes its position in the list.

void onRemoved(int position, int count)

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

Inherited methods

From class java.lang.Object
From interface android.support.v7.util.ListUpdateCallback

Public constructors

BatchingListUpdateCallback

added in version 24.2.0
BatchingListUpdateCallback (ListUpdateCallback callback)

Parameters
callback ListUpdateCallback

Public methods

dispatchLastEvent

added in version 24.2.0
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.

onChanged

added in version 24.2.0
void onChanged (int position, 
                int count, 
                Object payload)

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

Parameters
position int: The position of the item which has been updated.

count int: The number of items which has changed.

payload Object

onInserted

added in version 24.2.0
void onInserted (int position, 
                int count)

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

Parameters
position int: The position of the new item.

count int: The number of items that have been added.

onMoved

added in version 24.2.0
void onMoved (int fromPosition, 
                int toPosition)

Called when an item changes its position in the list.

Parameters
fromPosition int: The previous position of the item before the move.

toPosition int: The new position of the item.

onRemoved

added in version 24.2.0
void onRemoved (int position, 
                int count)

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

Parameters
position int: The position of the item which has been removed.

count int: The number of items which have been removed.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)