BatchingListUpdateCallback
public class BatchingListUpdateCallback implements ListUpdateCallback
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(@NonNull ListUpdateCallback callback) |
Public methods |
|
|---|---|
void |
BatchingListUpdateCallback holds onto the last event to see if it can be merged with the next one. |
void |
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. |
Public constructors
BatchingListUpdateCallback
public BatchingListUpdateCallback(@NonNull ListUpdateCallback callback)
Public methods
dispatchLastEvent
public 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
public void onChanged(int position, int count, Object payload)
Called when count} number of items are updated at the given position.
onInserted
public void onInserted(int position, int count)
Called when count} number of items are inserted at the given position.