# PagingDataAdapter

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

*** ** * ** ***


```
public abstract class PagingDataAdapter<T extends Object, VH extends RecyclerView.ViewHolder> extends RecyclerView.Adapter<@NonNull VH>
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [androidx.recyclerview.widget.RecyclerView.Adapter](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter)\<@[NonNull](https://developer.android.com/reference/androidx/annotation/NonNull) VH\> ||
|   | ↳ | [androidx.paging.PagingDataAdapter](https://developer.android.com/reference/androidx/paging/PagingDataAdapter) |

*** ** * ** ***

`https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter` base class for presenting paged data from `https://developer.android.com/reference/androidx/paging/PagingData`s in a `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView`.

This class is a convenience wrapper around `https://developer.android.com/reference/androidx/paging/AsyncPagingDataDiffer` that implements common default behavior for item counting, and listening to update events.

To present a `https://developer.android.com/reference/androidx/paging/Pager`, use `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/index.html` to observe `https://developer.android.com/reference/androidx/paging/Pager#flow()` and call `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)` whenever a new `https://developer.android.com/reference/androidx/paging/PagingData` is emitted.

If using RxJava and LiveData extensions on `https://developer.android.com/reference/androidx/paging/Pager`, use the non-suspending overload of `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)`, which accepts a `https://developer.android.com/reference/androidx/lifecycle/Lifecycle`.

`https://developer.android.com/reference/androidx/paging/PagingDataAdapter` listens to internal `https://developer.android.com/reference/androidx/paging/PagingData` loading events as `https://developer.android.com/reference/androidx/paging/PagingSource.LoadResult.Page` are loaded, and uses `https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil` on a background thread to compute fine grained updates as updated content in the form of new PagingData objects are received.

*State Restoration* : To be able to restore `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView` state (e.g. scroll position) after a configuration change / application recreate, `https://developer.android.com/reference/androidx/paging/PagingDataAdapter` calls `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#setStateRestorationPolicy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy)` with `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy#PREVENT` upon initialization and waits for the first page to load before allowing state restoration. Any other call to `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#setStateRestorationPolicy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy)` by the application will disable this logic and will rely on the user set value.

```kotlin
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.DiffUtil

val USER_COMPARATOR =
    object : DiffUtil.ItemCallback<User>() {
        override fun areItemsTheSame(oldItem: User, newItem: User): Boolean =
            // User ID serves as unique ID
            oldItem.userId == newItem.userId

        override fun areContentsTheSame(oldItem: User, newItem: User): Boolean =
            // Compare full contents (note: Java users should call .equals())
            oldItem == newItem
    }

class UserAdapter : PagingDataAdapter<User, UserViewHolder>(USER_COMPARATOR) {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): UserViewHolder {
        return UserViewHolder.create(parent)
    }

    override fun onBindViewHolder(holder: UserViewHolder, position: Int) {
        val repoItem = getItem(position)
        // Note that item may be null, ViewHolder must support binding null item as placeholder
        holder.bind(repoItem)
    }
}
```

## Summary

| ### Public constructors |
|---|
| `<T extends https://developer.android.com/reference/java/lang/Object.html, VH extends https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder> https://developer.android.com/reference/androidx/paging/PagingDataAdapter#PagingDataAdapter(androidx.recyclerview.widget.DiffUtil.ItemCallback,kotlin.coroutines.CoroutineContext,kotlin.coroutines.CoroutineContext)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/DiffUtil.ItemCallback<@https://developer.android.com/reference/androidx/annotation/NonNull T> diffCallback, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html mainDispatcher, @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.coroutines/-coroutine-context/index.html workerDispatcher )` |

| ### Public methods |
|---|---|
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#addLoadStateListener(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/CombinedLoadStates, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener )` Add a `https://developer.android.com/reference/androidx/paging/CombinedLoadStates` listener to observe the loading state of the current `https://developer.android.com/reference/androidx/paging/PagingData`. |
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#addOnPagesUpdatedListener(kotlin.Function0)(@https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener)` Add a listener which triggers after the pages presented to the UI are updated, even if the actual items presented don't change. |
| `int` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getItemCount()()` Returns the total number of items in the data set held by the adapter. |
| `int` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getItemCount()()` |
| `final long` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getItemId(kotlin.Int)(int position)` Note: `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getItemId(kotlin.Int)` is final, because stable IDs are unnecessary and therefore unsupported. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/CombinedLoadStates>` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getLoadStateFlow()()` A hot `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` of `https://developer.android.com/reference/androidx/paging/CombinedLoadStates` that emits a snapshot whenever the loading state of the current `https://developer.android.com/reference/androidx/paging/PagingData` changes. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html>` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getOnPagesUpdatedFlow()()` A hot `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` that emits after the pages presented to the UI are updated, even if the actual items presented don't change. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getStateRestorationPolicy()()` |
| `final T` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/paging/PagingDataAdapter#peek(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/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` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#refresh()()` Refresh the data presented by this `https://developer.android.com/reference/androidx/paging/PagingDataAdapter`. |
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#removeLoadStateListener(kotlin.Function1)( @https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/CombinedLoadStates, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener )` Remove a previously registered `https://developer.android.com/reference/androidx/paging/CombinedLoadStates` listener. |
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#removeOnPagesUpdatedListener(kotlin.Function0)(@https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener)` Remove a previously registered listener for new `https://developer.android.com/reference/androidx/paging/PagingData` generations completing initial load and presenting to the UI. |
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#retry()()` Retry any failed load requests that would result in a `https://developer.android.com/reference/androidx/paging/LoadState.Error` update to this `https://developer.android.com/reference/androidx/paging/PagingDataAdapter`. |
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#setHasStableIds(kotlin.Boolean)(boolean hasStableIds)` Stable ids are unsupported by `https://developer.android.com/reference/androidx/paging/PagingDataAdapter`. |
| `void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#setStateRestorationPolicy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy strategy )` Sets the state restoration strategy for the Adapter. |
| `void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#setStateRestorationPolicy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy strategy )` |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/ItemSnapshotList<@https://developer.android.com/reference/androidx/annotation/NonNull T>` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#snapshot()()` Returns a new `https://developer.android.com/reference/androidx/paging/ItemSnapshotList` representing the currently presented items, including any placeholders if they are enabled. |
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T> pagingData)` Present a `https://developer.android.com/reference/androidx/paging/PagingData` until it is invalidated by a call to `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#refresh()` or `https://developer.android.com/reference/androidx/paging/PagingSource#invalidate()`. |
| `final void` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/lifecycle/Lifecycle lifecycle, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/PagingData<@https://developer.android.com/reference/androidx/annotation/NonNull T> pagingData )` Present a `https://developer.android.com/reference/androidx/paging/PagingData` until it is either invalidated or another call to `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.lifecycle.Lifecycle,androidx.paging.PagingData)` is made. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateFooter(androidx.paging.LoadStateAdapter)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/LoadStateAdapter<@https://developer.android.com/reference/androidx/annotation/NonNull ?> footer)` Create a `https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` with the provided `https://developer.android.com/reference/androidx/paging/LoadStateAdapter`s displaying the `https://developer.android.com/reference/androidx/paging/LoadState` as a list item at the start of the presented list. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateHeader(androidx.paging.LoadStateAdapter)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/LoadStateAdapter<@https://developer.android.com/reference/androidx/annotation/NonNull ?> header)` Create a `https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` with the provided `https://developer.android.com/reference/androidx/paging/LoadStateAdapter`s displaying the `https://developer.android.com/reference/androidx/paging/LoadState` as a list item at the end of the presented list. |
| `final @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` | `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateHeaderAndFooter(androidx.paging.LoadStateAdapter,androidx.paging.LoadStateAdapter)( @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/LoadStateAdapter<@https://developer.android.com/reference/androidx/annotation/NonNull ?> header, @https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/LoadStateAdapter<@https://developer.android.com/reference/androidx/annotation/NonNull ?> footer )` Create a `https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` with the provided `https://developer.android.com/reference/androidx/paging/LoadStateAdapter`s displaying the `https://developer.android.com/reference/androidx/paging/LoadType#PREPEND` and `https://developer.android.com/reference/androidx/paging/LoadState`s as list items at the start and end respectively. |

| ### Protected methods |
|---|---|
| `final T` | `@https://developer.android.com/reference/androidx/annotation/MainThread https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getItem(kotlin.Int)(@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int position)` Returns the presented item at the specified position, notifying Paging of the item access to trigger any loads necessary to fulfill `https://developer.android.com/reference/androidx/paging/PagingConfig#prefetchDistance()`. |

### Inherited methods

From [androidx.recyclerview.widget.RecyclerView.Adapter](https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter) `final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#bindViewHolder(VH,int)(@https://developer.android.com/reference/androidx/annotation/NonNull VH holder, int position)` `final @https://developer.android.com/reference/androidx/annotation/NonNull VH` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#createViewHolder(android.view.ViewGroup,int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/ViewGroup.html parent, int viewType)` `int` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#findRelativeAdapterPositionIn(androidx.recyclerview.widget.RecyclerView.Adapter<? extends androidx.recyclerview.widget.RecyclerView.ViewHolder>,androidx.recyclerview.widget.RecyclerView.ViewHolder,int)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder> adapter,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder viewHolder,
int localPosition
)`

Returns the position of the given `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.ViewHolder` in the given `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter`.
`int` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#getItemViewType(int)(int position)`

Return the view type of the item at `position` for the purposes of view recycling.
`final boolean` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#hasObservers()()`

Returns true if one or more observers are attached to this adapter.
`final boolean` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#hasStableIds()()`

Returns true if this adapter publishes a unique `long` value that can act as a key for the item at a given position in the data set.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyDataSetChanged()()`

Notify any registered observers that the data set has changed.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemChanged(int)(int position)`

Notify any registered observers that the item at `position` has changed.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemChanged(int,java.lang.Object)(int position, @https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html payload)`

Notify any registered observers that the item at `position` has changed with an optional payload object.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemInserted(int)(int position)`

Notify any registered observers that the item reflected at `position` has been newly inserted.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemMoved(int,int)(int fromPosition, int toPosition)`

Notify any registered observers that the item reflected at `fromPosition` has been moved to `toPosition`.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeChanged(int,int)(int positionStart, int itemCount)`

Notify any registered observers that the `itemCount` items starting at position `positionStart` have changed.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeChanged(int,int,java.lang.Object)(
int positionStart,
int itemCount,
@https://developer.android.com/reference/androidx/annotation/Nullable https://developer.android.com/reference/java/lang/Object.html payload
)`

Notify any registered observers that the `itemCount` items starting at position `positionStart` have changed.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeInserted(int,int)(int positionStart, int itemCount)`

Notify any registered observers that the currently reflected `itemCount` items starting at `positionStart` have been newly inserted.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRangeRemoved(int,int)(int positionStart, int itemCount)`

Notify any registered observers that the `itemCount` items previously located at `positionStart` have been removed from the data set.
`final void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyItemRemoved(int)(int position)`

Notify any registered observers that the item previously located at `position` has been removed from the data set.
`void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onAttachedToRecyclerView(androidx.recyclerview.widget.RecyclerView)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView recyclerView)`

Called by RecyclerView when it starts observing this Adapter.
`abstract void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int)(@https://developer.android.com/reference/androidx/annotation/NonNull VH holder, int position)` `void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onBindViewHolder(VH,int,java.util.List<java.lang.Object>)(
@https://developer.android.com/reference/androidx/annotation/NonNull VH holder,
int position,
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/util/List.html<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/java/lang/Object.html> payloads
)` `abstract @https://developer.android.com/reference/androidx/annotation/NonNull VH` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onCreateViewHolder(android.view.ViewGroup,int)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/android/view/ViewGroup.html parent, int viewType)` `void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onDetachedFromRecyclerView(androidx.recyclerview.widget.RecyclerView)(@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView recyclerView)`

Called by RecyclerView when it stops observing this Adapter.
`boolean` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onFailedToRecycleView(VH)(@https://developer.android.com/reference/androidx/annotation/NonNull VH holder)` `void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onViewAttachedToWindow(VH)(@https://developer.android.com/reference/androidx/annotation/NonNull VH holder)` `void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onViewDetachedFromWindow(VH)(@https://developer.android.com/reference/androidx/annotation/NonNull VH holder)` `void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#onViewRecycled(VH)(@https://developer.android.com/reference/androidx/annotation/NonNull VH holder)` `void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#registerAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.AdapterDataObserver observer
)`

Register a new observer to listen for data changes.
`void` `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#unregisterAdapterDataObserver(androidx.recyclerview.widget.RecyclerView.AdapterDataObserver)(
@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.AdapterDataObserver observer
)`

Unregister an observer currently listening for data changes.

## Public constructors

### PagingDataAdapter

```
public <T extends Object, VH extends RecyclerView.ViewHolder> PagingDataAdapter(
    @NonNull DiffUtil.ItemCallback<@NonNull T> diffCallback,
    @NonNull CoroutineContext mainDispatcher,
    @NonNull CoroutineContext workerDispatcher
)
```

## Public methods

### addLoadStateListener

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

```
public final void addLoadStateListener(
    @NonNull Function1<@NonNull CombinedLoadStates, Unit> listener
)
```

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

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

```kotlin
import androidx.paging.LoadState

val adapter = UserPagingAdapter()
adapter.addLoadStateListener {
    // show a retry button outside the list when refresh hits an error
    retryButton.isVisible = it.refresh is LoadState.Error

    // swipeRefreshLayout displays whether refresh is occurring
    swipeRefreshLayout.isRefreshing = it.refresh is LoadState.Loading

    // show an empty state over the list when loading initially, before items are loaded
    emptyState.isVisible = it.refresh is LoadState.Loading && adapter.itemCount == 0
}
```

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/CombinedLoadStates, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener` | `https://developer.android.com/reference/androidx/paging/LoadStates` listener to receive updates. |

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

### addOnPagesUpdatedListener

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

```
public final void addOnPagesUpdatedListener(@NonNull Function0<Unit> listener)
```

Add a listener which triggers after the pages presented to the UI are updated, even if the actual items presented don't change.

An update is triggered from one of the following:

- `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)` is called and initial load completes, regardless of any differences in the loaded data

- A `https://developer.android.com/reference/androidx/paging/PagingSource.LoadResult.Page` is inserted

- A `https://developer.android.com/reference/androidx/paging/PagingSource.LoadResult.Page` is dropped

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener` | called after pages presented are updated. |

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

### getItemCount

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

```
public int getItemCount()
```

Returns the total number of items in the data set held by the adapter.

| Returns |
|---|---|
| `int` | The total number of items in this adapter. |

### getItemCount

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

```
public int getItemCount()
```

### getItemId

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

```
public final long getItemId(int position)
```

Note: `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#getItemId(kotlin.Int)` is final, because stable IDs are unnecessary and therefore unsupported.

`https://developer.android.com/reference/androidx/paging/PagingDataAdapter`'s async diffing means that efficient change animations are handled for you, without the performance drawbacks of `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#notifyDataSetChanged()`. Instead, the diffCallback parameter of the `https://developer.android.com/reference/androidx/paging/PagingDataAdapter` serves the same functionality - informing the adapter and `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView` how items are changed and moved.

### getLoadStateFlow

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

```
public final @NonNull Flow<@NonNull CombinedLoadStates> getLoadStateFlow()
```

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

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

### getOnPagesUpdatedFlow

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

```
public final @NonNull Flow<Unit> getOnPagesUpdatedFlow()
```

A hot `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` that emits after the pages presented to the UI are updated, even if the actual items presented don't change.

An update is triggered from one of the following:

- `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)` is called and initial load completes, regardless of any differences in the loaded data

- A `https://developer.android.com/reference/androidx/paging/PagingSource.LoadResult.Page` is inserted

- A `https://developer.android.com/reference/androidx/paging/PagingSource.LoadResult.Page` is dropped

Note: This is a `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-shared-flow/index.html` configured to replay 0 items with a buffer of size 64. If a collector lags behind page updates, it may trigger multiple times for each intermediate update that was presented while your collector was still working. To avoid this behavior, you can `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/index.html` this `https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html` so that you only receive the latest update, which is useful in cases where you are simply updating UI and don't care about tracking the exact number of page updates.

### getStateRestorationPolicy

```
public final @NonNull RecyclerView.Adapter.StateRestorationPolicy getStateRestorationPolicy()
```

### peek

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

```
@MainThread
public 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.

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

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

### refresh

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

```
public final void refresh()
```

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

`https://developer.android.com/reference/androidx/paging/PagingDataAdapter#refresh()` triggers the creation of a new `https://developer.android.com/reference/androidx/paging/PagingData` with a new instance of `https://developer.android.com/reference/androidx/paging/PagingSource` to represent an updated snapshot of the backing dataset. If a `https://developer.android.com/reference/androidx/paging/RemoteMediator` is set, calling `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#refresh()` will also trigger a call to `https://developer.android.com/reference/androidx/paging/RemoteMediator#load(androidx.paging.LoadType,androidx.paging.PagingState)` with `https://developer.android.com/reference/androidx/paging/LoadType#REFRESH` to allow `https://developer.android.com/reference/androidx/paging/RemoteMediator` to check for updates to the dataset backing `https://developer.android.com/reference/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/androidx/paging/PagingSource#invalidate()`.

```kotlin
import androidx.appcompat.app.AppCompatActivity
import androidx.paging.LoadState

class MyActivity : AppCompatActivity() {
    private lateinit var binding: MyActivityBinding
    private val pagingAdapter = UserPagingAdapter()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding = MyActivityBinding.inflate(layoutInflater)
        setContentView(binding.root)

        binding.recyclerView.adapter = pagingAdapter
        pagingAdapter.addLoadStateListener { loadStates ->
            binding.swipeRefreshLayout.isRefreshing = loadStates.refresh is LoadState.Loading
        }

        binding.swipeRefreshLayout.setOnRefreshListener { pagingAdapter.refresh() }
    }
}
```

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

### removeLoadStateListener

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

```
public final void removeLoadStateListener(
    @NonNull Function1<@NonNull CombinedLoadStates, Unit> listener
)
```

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

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function1<@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/paging/CombinedLoadStates, https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener` | Previously registered listener. |

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

### removeOnPagesUpdatedListener

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

```
public final void removeOnPagesUpdatedListener(@NonNull Function0<Unit> listener)
```

Remove a previously registered listener for new `https://developer.android.com/reference/androidx/paging/PagingData` generations completing initial load and presenting to the UI.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull Function0<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html> listener` | Previously registered listener. |

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

### retry

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

```
public final void retry()
```

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

Unlike `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#refresh()`, this does not invalidate `https://developer.android.com/reference/androidx/paging/PagingSource`, it only retries failed loads within the same generation of `https://developer.android.com/reference/androidx/paging/PagingData`.

`https://developer.android.com/reference/androidx/paging/LoadState.Error` can be generated from two types of load requests:

- `https://developer.android.com/reference/androidx/paging/PagingSource#load(androidx.paging.PagingSource.LoadParams)` returning `https://developer.android.com/reference/androidx/paging/PagingSource.LoadResult.Error`

- `https://developer.android.com/reference/androidx/paging/RemoteMediator#load(androidx.paging.LoadType,androidx.paging.PagingState)` returning `https://developer.android.com/reference/androidx/paging/RemoteMediator.MediatorResult.Error`

### setHasStableIds

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

```
public final void setHasStableIds(boolean hasStableIds)
```

Stable ids are unsupported by `https://developer.android.com/reference/androidx/paging/PagingDataAdapter`. Calling this method is an error and will result in an `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html`.

| Parameters |
|---|---|
| `boolean hasStableIds` | Whether items in data set have unique identifiers or not. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unsupported-operation-exception/index.html` | Always thrown, since this is unsupported by `https://developer.android.com/reference/androidx/paging/PagingDataAdapter`. |

### setStateRestorationPolicy

```
public void setStateRestorationPolicy(
    @NonNull RecyclerView.Adapter.StateRestorationPolicy strategy
)
```

Sets the state restoration strategy for the Adapter. By default, it is set to `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy#ALLOW` which means RecyclerView expects any set Adapter to be immediately capable of restoring the RecyclerView's saved scroll position.

This behaviour might be undesired if the Adapter's data is loaded asynchronously, and thus unavailable during initial layout (e.g. after Activity rotation). To avoid losing scroll position, you can change this to be either `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy#PREVENT_WHEN_EMPTY` or `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy#PREVENT`. Note that the former means your RecyclerView will restore state as soon as Adapter has 1 or more items while the latter requires you to call `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#setStateRestorationPolicy(androidx.recyclerview.widget.RecyclerView.Adapter.StateRestorationPolicy)` with either `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy#ALLOW` or `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy#PREVENT_WHEN_EMPTY` again when the Adapter is ready to restore its state.

RecyclerView will still layout even when State restoration is disabled. The behavior of how State is restored is up to the `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager`. All default LayoutManagers will override current state with restored state when state restoration happens (unless an explicit call to `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.LayoutManager#scrollToPosition(int)` is made).

Calling this method after state is restored will not have any effect other than changing the return value of `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#getStateRestorationPolicy()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/NonNull https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter.StateRestorationPolicy strategy` | The saved state restoration strategy for this Adapter. |

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter#getStateRestorationPolicy()` |   |

### setStateRestorationPolicy

```
public void setStateRestorationPolicy(
    @NonNull RecyclerView.Adapter.StateRestorationPolicy strategy
)
```

### snapshot

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

```
public final @NonNull ItemSnapshotList<@NonNull T> snapshot()
```

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

### submitData

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

```
public final void submitData(@NonNull PagingData<@NonNull T> pagingData)
```

Present a `https://developer.android.com/reference/androidx/paging/PagingData` until it is invalidated by a call to `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#refresh()` or `https://developer.android.com/reference/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/androidx/paging/Pager`. For RxJava or LiveData support, use the non-suspending overload of `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#submitData(androidx.paging.PagingData)`, which accepts a `https://developer.android.com/reference/androidx/lifecycle/Lifecycle`.

Note: This method suspends while it is actively presenting page loads from a `https://developer.android.com/reference/androidx/paging/PagingData`, until the `https://developer.android.com/reference/androidx/paging/PagingData` is invalidated. Although cancellation will propagate to this call automatically, collecting from a `https://developer.android.com/reference/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`.

```kotlin
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope

class MyFlowActivity : AppCompatActivity() {
    val pagingAdapter = UserPagingAdapter()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val viewModel by viewModels<UserListViewModel>()

        lifecycleScope.launch {
            viewModel.pagingFlow.collectLatest { pagingData ->
                // submitData suspends until loading this generation of data stops
                // so be sure to use collectLatest {} when presenting a Flow<PagingData>
                pagingAdapter.submitData(pagingData)
            }
        }
    }
}
```

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

### submitData

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

```
public final void submitData(
    @NonNull Lifecycle lifecycle,
    @NonNull PagingData<@NonNull T> pagingData
)
```

Present a `https://developer.android.com/reference/androidx/paging/PagingData` until it is either invalidated or another call to `https://developer.android.com/reference/androidx/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/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/androidx/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/androidx/lifecycle/Lifecycle`.

```kotlin
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity

class MyLiveDataActivity : AppCompatActivity() {
    val pagingAdapter = UserPagingAdapter()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val viewModel by viewModels<UserListViewModel>()

        viewModel.pagingLiveData.observe(this) { pagingData ->
            pagingAdapter.submitData(lifecycle, pagingData)
        }
    }
}
```

```kotlin
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity

class MyRxJava2Activity : AppCompatActivity() {
    val pagingAdapter = UserPagingAdapter()
    val disposable = CompositeDisposable()

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val viewModel by viewModels<UserListViewModel>()

        viewModel.pagingFlowable
            .autoDispose(this) // Using AutoDispose to handle subscription lifecycle
            .subscribe { pagingData -> pagingAdapter.submitData(lifecycle, pagingData) }
    }
}
```

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

### withLoadStateFooter

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

```
public final @NonNull ConcatAdapter withLoadStateFooter(@NonNull LoadStateAdapter<@NonNull ?> footer)
```

Create a `https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` with the provided `https://developer.android.com/reference/androidx/paging/LoadStateAdapter`s displaying the `https://developer.android.com/reference/androidx/paging/LoadState` as a list item at the start of the presented list.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/paging/LoadStateAdapter` |   |
| `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateHeaderAndFooter(androidx.paging.LoadStateAdapter,androidx.paging.LoadStateAdapter)` |   |
| `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateHeader(androidx.paging.LoadStateAdapter)` |   |

### withLoadStateHeader

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

```
public final @NonNull ConcatAdapter withLoadStateHeader(@NonNull LoadStateAdapter<@NonNull ?> header)
```

Create a `https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` with the provided `https://developer.android.com/reference/androidx/paging/LoadStateAdapter`s displaying the `https://developer.android.com/reference/androidx/paging/LoadState` as a list item at the end of the presented list.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/paging/LoadStateAdapter` |   |
| `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateHeaderAndFooter(androidx.paging.LoadStateAdapter,androidx.paging.LoadStateAdapter)` |   |
| `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateFooter(androidx.paging.LoadStateAdapter)` |   |

### withLoadStateHeaderAndFooter

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

```
public final @NonNull ConcatAdapter withLoadStateHeaderAndFooter(
    @NonNull LoadStateAdapter<@NonNull ?> header,
    @NonNull LoadStateAdapter<@NonNull ?> footer
)
```

Create a `https://developer.android.com/reference/androidx/recyclerview/widget/ConcatAdapter` with the provided `https://developer.android.com/reference/androidx/paging/LoadStateAdapter`s displaying the `https://developer.android.com/reference/androidx/paging/LoadType#PREPEND` and `https://developer.android.com/reference/androidx/paging/LoadState`s as list items at the start and end respectively.

| See also |
|---|---|
| `https://developer.android.com/reference/androidx/paging/LoadStateAdapter` |   |
| `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateHeader(androidx.paging.LoadStateAdapter)` |   |
| `https://developer.android.com/reference/androidx/paging/PagingDataAdapter#withLoadStateFooter(androidx.paging.LoadStateAdapter)` |   |

## Protected methods

### getItem

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

```
@MainThread
protected final T getItem(@IntRange(from = 0) int position)
```

Returns the presented item at the specified position, notifying Paging of the item access to trigger any loads necessary to fulfill `https://developer.android.com/reference/androidx/paging/PagingConfig#prefetchDistance()`.

| Parameters |
|---|---|
| `@https://developer.android.com/reference/androidx/annotation/IntRange(from = 0) int position` | Index of the presented item to return, including placeholders. |

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