The second Android 11 Developer Preview is now available, test it out and share your feedback.

ListUpdateCallback

interface ListUpdateCallback
androidx.recyclerview.widget.ListUpdateCallback

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 methods

abstract Unit
onChanged(position: Int, count: Int, @Nullable payload: Any?)

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

abstract Unit
onInserted(position: Int, count: Int)

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

abstract Unit
onMoved(fromPosition: Int, toPosition: Int)

Called when an item changes its position in the list.

abstract Unit
onRemoved(position: Int, count: Int)

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

Public methods

onChanged

abstract fun onChanged(
    position: Int,
    count: Int,
    @Nullable payload: Any?
): Unit

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.

onInserted

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

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

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

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

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

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.