Register now for Android Dev Summit 2019!

AdapterListUpdateCallback

class AdapterListUpdateCallback : ListUpdateCallback
kotlin.Any
   ↳ androidx.recyclerview.widget.AdapterListUpdateCallback

ListUpdateCallback that dispatches update events to the given adapter.

Summary

Public constructors

Creates an AdapterListUpdateCallback that will dispatch update events to the given adapter.

Public methods

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

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

Unit
onInserted(position: Int, count: Int)

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

Unit
onMoved(fromPosition: Int, toPosition: Int)

Called when an item changes its position in the list.

Unit
onRemoved(position: Int, count: Int)

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

Public constructors

<init>

AdapterListUpdateCallback(@NonNull adapter: RecyclerView.Adapter<RecyclerView.ViewHolder!>)

Creates an AdapterListUpdateCallback that will dispatch update events to the given adapter.

Parameters
adapter RecyclerView.Adapter<RecyclerView.ViewHolder!>: The Adapter to send updates to.

Public methods

onChanged

fun onChanged(position: Int, count: Int, 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

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

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

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.