PagingDataAdapter

public final class PagingDataAdapter<T extends Object> extends ObjectAdapter

Object
   ↳ ObjectAdapter
     ↳ PagingDataAdapter

An ObjectAdapter implemented with an AsyncPagingDataDiffer. It is an analogue of androidx.paging.PagingDataAdapter for leanback widgets.

Parameters
<T extends Object>

Type of the item in the list.

Summary

Public fields

final @NonNull Flow<@NonNull CombinedLoadStates>

A hot Flow of CombinedLoadStates that emits a snapshot whenever the loading state of the current PagingData changes.

Public constructors

<T extends Object> PagingDataAdapter(
    DiffUtil.ItemCallback<T> diffCallback,
    CoroutineDispatcher mainDispatcher,
    CoroutineDispatcher workerDispatcher
)

Constructs an adapter

<T extends Object> PagingDataAdapter(
    Presenter presenter,
    DiffUtil.ItemCallback<T> diffCallback,
    CoroutineDispatcher mainDispatcher,
    CoroutineDispatcher workerDispatcher
)

Constructs an adapter

<T extends Object> PagingDataAdapter(
    PresenterSelector presenterSelector,
    DiffUtil.ItemCallback<T> diffCallback,
    CoroutineDispatcher mainDispatcher,
    CoroutineDispatcher workerDispatcher
)

Constructs an adapter

Public methods

final void

Add a CombinedLoadStates listener to observe the loading state of the current PagingData.

T
get(int position)

Returns the item for the given position.

final T
peek(@IntRange(from = 0) int index)

Returns the presented item at the specified position, without notifying Paging of the item access that would normally trigger page loads.

final void

Refresh the data presented by this PagingDataAdapter.

final void

Remove a previously registered CombinedLoadStates listener.

final void

Retry any failed load requests that would result in a LoadState.Error update to this

int
final @NonNull ItemSnapshotList<@NonNull T>

Returns a new ItemSnapshotList representing the currently presented items, including any placeholders if they are enabled.

final void
submitData(PagingData<T> pagingData)

Present a PagingData until it is invalidated by a call to refresh or PagingSource.invalidate.

final void
submitData(Lifecycle lifecycle, PagingData<T> pagingData)

Present a PagingData until it is either invalidated or another call to submitData is made.

Inherited methods

From class ObjectAdapter
long
getId(int position)
final @NonNull Presenter
final @NonNull PresenterSelector
final @RestrictTo(value = RestrictTo.Scope.LIBRARY_GROUP_PREFIX) boolean
final boolean
boolean
final void
final void
notifyItemMoved(int fromPosition, int toPosition)
final void
notifyItemRangeChanged(int positionStart, int itemCount)
final void
notifyItemRangeChanged(int positionStart, int itemCount, Object payload)
final void
notifyItemRangeInserted(int positionStart, int itemCount)
final void
notifyItemRangeRemoved(int positionStart, int itemCount)
void
void
final void
final void
setHasStableIds(boolean hasStableIds)
final void