# PagingDataAdapter

Artifact: [androidx.leanback:leanback-paging](https://developer.android.com/jetpack/androidx/releases/leanback) [View Source](https://cs.android.com/search?q=file:androidx/leanback/paging/PagingDataAdapter.kt+class:androidx.leanback.paging.PagingDataAdapter) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

*** ** * ** ***

<br />

```
class PagingDataAdapter<T : Any> : ObjectAdapter
```

<br />

|---|---|---|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html) |||
| ↳ | [androidx.leanback.widget.ObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter) ||
|   | ↳ | [androidx.leanback.paging.PagingDataAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter) |

*** ** * ** ***

An `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter` implemented with an `https://developer.android.com/reference/kotlin/androidx/paging/AsyncPagingDataDiffer`. It is an analogue of `https://developer.android.com/reference/kotlin/androidx/paging/PagingDataAdapter` for leanback widgets.

| Parameters |
|---|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html>` | Type of the item in the list. |

## Summary

| ### Public constructors |
|---|
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#PagingDataAdapter(androidx.recyclerview.widget.DiffUtil.ItemCallback,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)( diffCallback: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback<T>, mainDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html, workerDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html )` Constructs an adapter |
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#PagingDataAdapter(androidx.leanback.widget.Presenter,androidx.recyclerview.widget.DiffUtil.ItemCallback,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)( presenter: https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter, diffCallback: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback<T>, mainDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html, workerDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html )` Constructs an adapter |
| `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html> https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#PagingDataAdapter(androidx.leanback.widget.PresenterSelector,androidx.recyclerview.widget.DiffUtil.ItemCallback,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)( presenterSelector: https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector, diffCallback: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback<T>, mainDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html, workerDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html )` Constructs an adapter |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#addLoadStateListener(kotlin.Function1)(listener: (https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Add a `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` listener to observe the loading state of the current `https://developer.android.com/reference/kotlin/androidx/paging/PagingData`. |
| `open operator T?` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#get(kotlin.Int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the item for the given position. |
| `T?` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#peek(kotlin.Int)(index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the presented item at the specified position, without notifying Paging of the item access that would normally trigger page loads. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#refresh()()` Refresh the data presented by this `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#removeLoadStateListener(kotlin.Function1)(listener: (https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)` Remove a previously registered `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` listener. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#retry()()` Retry any failed load requests that would result in a `https://developer.android.com/reference/kotlin/androidx/paging/LoadState.Error` update to this |
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#size()()` |
| `https://developer.android.com/reference/kotlin/androidx/paging/ItemSnapshotList<T>` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#snapshot()()` Returns a new `https://developer.android.com/reference/kotlin/androidx/paging/ItemSnapshotList` representing the currently presented items, including any placeholders if they are enabled. |
| `suspend https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)(pagingData: https://developer.android.com/reference/kotlin/androidx/paging/PagingData<T>)` Present a `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` until it is invalidated by a call to `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#refresh()` or `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()`. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)(lifecycle: https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle, pagingData: https://developer.android.com/reference/kotlin/androidx/paging/PagingData<T>)` Present a `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` until it is either invalidated or another call to `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)` is made. |

| ### Public properties |
|---|---|
| `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates>` | `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#loadStateFlow()` A hot `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` of `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` that emits a snapshot whenever the loading state of the current `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` changes. |

### Inherited functions

From [androidx.leanback.widget.ObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#getId(int)(position: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Returns the id for the given position.
`https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter?` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#getPresenter(java.lang.Object)(item: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)`

Returns the `https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter` for the given item from the adapter.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#hasStableIds()()`

Returns true if the item ids are stable across changes to the underlying data.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyChanged()()`

Notifies UI that the underlying data has changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemMoved(int,int)(fromPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, toPosition: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notifies UI that item at fromPosition has been moved to toPosition.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeChanged(int,int)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notifies UI that some items has changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeChanged(int,int,java.lang.Object)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, payload: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)`

Notifies UI that some items has changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeInserted(int,int)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notifies UI that new items has been inserted.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#notifyItemRangeRemoved(int,int)(positionStart: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html, itemCount: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)`

Notifies UI that some items that has been removed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#onHasStableIdsChanged()()`

Called when `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#setHasStableIds(boolean)` is called and the status of stable ids has changed.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#onPresenterSelectorChanged()()`

Called when `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#setPresenterSelector(androidx.leanback.widget.PresenterSelector)` is called and the PresenterSelector differs from the previous one.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#registerObserver(androidx.leanback.widget.ObjectAdapter.DataObserver)(observer: https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver)`

Registers a DataObserver for data change notifications.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#setHasStableIds(boolean)(hasStableIds: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)`

Sets whether the item ids are stable across changes to the underlying data.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#unregisterAllObservers()()`

Unregisters all DataObservers for this ObjectAdapter.
`https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#unregisterObserver(androidx.leanback.widget.ObjectAdapter.DataObserver)(observer: https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter.DataObserver)`

Unregisters a DataObserver for data change notifications.

### Inherited properties

From [androidx.leanback.widget.ObjectAdapter](https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter) `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#isImmediateNotifySupported()` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector` `https://developer.android.com/reference/kotlin/androidx/leanback/widget/ObjectAdapter#presenterSelector()`

## Public constructors

### PagingDataAdapter

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

Constructs an adapter

| Parameters |
|---|---|
| `diffCallback: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback<T>` | The `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback` instance to compare items in the list. |
| `mainDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html = Dispatchers.Main` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to be used for foreground operations |
| `workerDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html = Dispatchers.Default` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to be used for computing diff |

### PagingDataAdapter

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

Constructs an adapter

| Parameters |
|---|---|
| `presenter: https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter` | `https://developer.android.com/reference/kotlin/androidx/leanback/widget/Presenter` |
| `diffCallback: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback<T>` | The `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback` instance to compare items in the list. |
| `mainDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html = Dispatchers.Main` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to be used for foreground operations |
| `workerDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html = Dispatchers.Default` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to be used for computing diff |

### PagingDataAdapter

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

Constructs an adapter

| Parameters |
|---|---|
| `presenterSelector: https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector` | `https://developer.android.com/reference/kotlin/androidx/leanback/widget/PresenterSelector` |
| `diffCallback: https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback<T>` | The `https://developer.android.com/reference/kotlin/androidx/recyclerview/widget/DiffUtil.ItemCallback` instance to compare items in the list. |
| `mainDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html = Dispatchers.Main` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to be used for foreground operations |
| `workerDispatcher: https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html = Dispatchers.Default` | The `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html` to be used for computing diff |

## Public functions

### addLoadStateListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
fun addLoadStateListener(listener: (CombinedLoadStates) -> Unit): Unit
```

Add a `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` listener to observe the loading state of the current `https://developer.android.com/reference/kotlin/androidx/paging/PagingData`.

As new `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` generations are submitted and displayed, the listener will be notified to reflect the current `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates`.

| Parameters |
|---|---|
| `listener: (https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` listener to receive updates. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#removeLoadStateListener(kotlin.Function1)` |   |

### get

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
open operator fun get(position: Int): T?
```

Returns the item for the given position. It will return null if placeholders are enabled and data is not yet loaded.

### peek

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
fun peek(index: @IntRange(from = 0) Int): T?
```

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

| Parameters |
|---|---|
| `index: @https://developer.android.com/reference/kotlin/androidx/annotation/IntRange(from = 0) https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Index of the presented item to return, including placeholders. |

| Returns |
|---|---|
| `T?` | The presented item at position `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#peek(kotlin.Int)`, `null` if it is a placeholder. |

### refresh

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
fun refresh(): Unit
```

Refresh the data presented by this `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter`.

`https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#refresh()` triggers the creation of a new `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` with a new instance of `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource` to represent an updated snapshot of the backing dataset. If a `https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator` is set, calling `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#refresh()` will also trigger a call to `https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator#load(androidx.paging.LoadType,androidx.paging.PagingState)` with `https://developer.android.com/reference/kotlin/androidx/paging/LoadType` REFRESH\] to allow `https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator` to check for updates to the dataset backing `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource`.

Note: This API is intended for UI-driven refresh signals, such as swipe-to-refresh. Invalidation due repository-layer signals, such as DB-updates, should instead use `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()` |   |

### removeLoadStateListener

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
fun removeLoadStateListener(listener: (CombinedLoadStates) -> Unit): Unit
```

Remove a previously registered `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` listener.

| Parameters |
|---|---|
| `listener: (https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates) -> https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | Previously registered listener. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#addLoadStateListener(kotlin.Function1)` |   |

### retry

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
fun retry(): Unit
```

Retry any failed load requests that would result in a `https://developer.android.com/reference/kotlin/androidx/paging/LoadState.Error` update to this

`https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter`.

`https://developer.android.com/reference/kotlin/androidx/paging/LoadState.Error` can be generated from two types of load requests: `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` returning `https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator#load(androidx.paging.LoadType,androidx.paging.PagingState)` returning `https://developer.android.com/reference/kotlin/androidx/paging/RemoteMediator.MediatorResult.Error`

### size

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
open fun size(): Int
```

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | Total number of presented items, including placeholders. |

### snapshot

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
fun snapshot(): ItemSnapshotList<T>
```

Returns a new `https://developer.android.com/reference/kotlin/androidx/paging/ItemSnapshotList` representing the currently presented items, including any placeholders if they are enabled.

### submitData

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
suspend fun submitData(pagingData: PagingData<T>): Unit
```

Present a `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` until it is invalidated by a call to `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#refresh()` or `https://developer.android.com/reference/kotlin/androidx/paging/PagingSource#invalidate()`.

This method is typically used when collecting from a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` produced by `https://developer.android.com/reference/kotlin/androidx/paging/Pager`. For RxJava or LiveData support, use the non-suspending overload of `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)`, which accepts a `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle`.

Note: This method suspends while it is actively presenting page loads from a `https://developer.android.com/reference/kotlin/androidx/paging/PagingData`, until the `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` is invalidated. Although cancellation will propagate to this call automatically, collecting from a `https://developer.android.com/reference/kotlin/androidx/paging/Pager#flow()` with the intention of presenting the most up-to-date representation of your backing dataset should typically be done using `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/index.html`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/paging/Pager` |   |

### submitData

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

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

Present a `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` until it is either invalidated or another call to `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)` is made.

This method is typically used when observing a RxJava or LiveData stream produced by `https://developer.android.com/reference/kotlin/androidx/paging/Pager`. For `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` support, use the suspending overload of `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)`, which automates cancellation via `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html` instead of relying of `https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle`.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/leanback/paging/PagingDataAdapter#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)` |   |
| `https://developer.android.com/reference/kotlin/androidx/paging/Pager` |   |

## Public properties

### loadStateFlow

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/leanback#1.1.0)

```
val loadStateFlow: Flow<CombinedLoadStates>
```

A hot `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` of `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` that emits a snapshot whenever the loading state of the current `https://developer.android.com/reference/kotlin/androidx/paging/PagingData` changes.

This flow is conflated, so it buffers the last update to `https://developer.android.com/reference/kotlin/androidx/paging/CombinedLoadStates` and immediately delivers the current load states on collection.