Package 

Class BatchingListUpdateCallback

  • All Implemented Interfaces:
    tds.androidx.recyclerview.widget.ListUpdateCallback

    
    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.

    • Method Summary

      Modifier and Type Method Description
      void dispatchLastEvent() BatchingListUpdateCallback holds onto the last event to see if it can be merged with thenext one.
      void onInserted(int position, int count) Called when {@code count} number of items are inserted at the given position.
      void onRemoved(int position, int count) Called when {@code count} number of items are removed from the given position.
      void onMoved(int fromPosition, int toPosition) Called when an item changes its position in the list.
      void onChanged(int position, int count, Object payload) Called when {@code count} number of items are updated at the given position.
      • Methods inherited from class tds.androidx.recyclerview.widget.ListUpdateCallback

        onChanged
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

    • Method Detail

      • dispatchLastEvent

         void dispatchLastEvent()

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

      • onInserted

         void onInserted(int position, int count)

        Called when {@code count} number of items are inserted at the given position.

        Parameters:
        position - The position of the new item.
        count - The number of items that have been added.
      • onRemoved

         void onRemoved(int position, int count)

        Called when {@code count} number of items are removed from the given position.

        Parameters:
        position - The position of the item which has been removed.
        count - The number of items which have been removed.
      • onMoved

         void onMoved(int fromPosition, int toPosition)

        Called when an item changes its position in the list.

        Parameters:
        fromPosition - The previous position of the item before the move.
        toPosition - The new position of the item.
      • onChanged

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

        Called when {@code count} number of items are updated at the given position.

        Parameters:
        position - The position of the item which has been updated.
        count - The number of items which has changed.