Google is committed to advancing racial equity for Black communities. See how.

PagingDataAdapter

class PagingDataAdapter<T : Any> : ObjectAdapter
kotlin.Any
   ↳ androidx.leanback.widget.ObjectAdapter
   ↳ androidx.leanback.paging.PagingDataAdapter

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

Summary

Public constructors
<init>(diffCallback: DiffUtil.ItemCallback<T>, mainDispatcher: CoroutineDispatcher = Dispatchers.Main, workerDispatcher: CoroutineDispatcher = Dispatchers.Default)

Constructs an adapter

<init>(presenter: Presenter, diffCallback: DiffUtil.ItemCallback<T>, mainDispatcher: CoroutineDispatcher = Dispatchers.Main, workerDispatcher: CoroutineDispatcher = Dispatchers.Default)

Constructs an adapter

<init>(presenterSelector: PresenterSelector, diffCallback: DiffUtil.ItemCallback<T>, mainDispatcher: CoroutineDispatcher = Dispatchers.Main, workerDispatcher: CoroutineDispatcher = Dispatchers.Default)

Constructs an adapter

Public methods
Unit

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

T?
get(position: Int)

Returns the item for the given position.

Unit

Refresh the data presented by this PagingDataAdapter.

Unit

Remove a previously registered CombinedLoadStates listener.

Unit

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

Int

suspend Unit
submitData(pagingData: PagingData<T>)

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

Unit
submitData(lifecycle: Lifecycle, pagingData: PagingData<T>)

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

Inherited functions
Properties
Flow<CombinedLoadStates>

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

Public constructors

<init>

PagingDataAdapter(
    diffCallback: DiffUtil.ItemCallback<T>,
    mainDispatcher: CoroutineDispatcher = Dispatchers.Main,
    workerDispatcher: CoroutineDispatcher = Dispatchers.Default)

Constructs an adapter

Parameters
diffCallback: DiffUtil.ItemCallback<T> The DiffUtil.ItemCallback instance to compare items in the list.
mainDispatcher: CoroutineDispatcher = Dispatchers.Main The CoroutineDispatcher to be used for foreground operations
workerDispatcher: CoroutineDispatcher = Dispatchers.Default The CoroutineDispatcher to be used for computing diff

<init>

PagingDataAdapter(
    presenter: Presenter,