blob: a52c47f85d144e105841f7a6dfb60e733b01605f [file] [log] [blame]
<html devsite="true">
<head>
<title>AsyncPagingDataDiffer</title>
{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %}
{% include "_shared/_reference-head-tags.html" %}
</head>
<body>
<h1>AsyncPagingDataDiffer</h1>
{% setvar page_path %}androidx/paging/AsyncPagingDataDiffer.html{% endsetvar %}
{% setvar can_switch %}1{% endsetvar %}
{% include "reference/_java_switcher2.md" %}
<p>
<pre>public final class AsyncPagingDataDiffer&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt;</pre>
</p>
<hr>
<p>Helper class for mapping a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> into a <a href="[androidx.recyclerview.widget.RecyclerView.Adapter]">androidx.recyclerview.widget.RecyclerView.Adapter</a>.</p>
<p>For simplicity, <code><a href="/reference/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> can often be used in place of this class. <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code> is exposed for complex cases, and where overriding <code><a href="/reference/androidx/paging/PagingDataAdapter.html">PagingDataAdapter</a></code> to support paging isn't convenient.</p>
<h2>Summary</h2>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public fields</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>final @<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#dataRefreshFlow()">dataRefreshFlow</a></code></div>
<p><strong>This field is deprecated.</strong> dataRefreshFlow is now redundant with the information passed from loadStateFlow and getItemCount, and will be removed in a future alpha version</p>
</td>
</tr>
<tr>
<td><code>final int</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a></code></div>
<p>Get the number of items currently presented by this Differ.</p>
</td>
</tr>
<tr>
<td><code>final @<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-opt-in/index.html">OptIn</a>(markerClass&nbsp;=&nbsp;[FlowPreview])&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#loadStateFlow()">loadStateFlow</a></code></div>
<p>A hot <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> of <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> that emits a snapshot whenever the loading state of the current <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> changes.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public constructors</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<div><code>&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#AsyncPagingDataDiffer(,,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)">AsyncPagingDataDiffer</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;T&gt;&nbsp;diffCallback,<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&nbsp;updateCallback,<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a>&nbsp;mainDispatcher,<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a>&nbsp;workerDispatcher<br>)</code></div>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2"><h3>Public methods</h3></th>
</tr>
</thead>
<tbody>
<tr>
<td><code>final @<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;void</code></td>
<td width="100%">
<div><code><span><del><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</a></del></span>(Function1&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</code></div>
<p><strong>This method is deprecated.</strong> dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</p>
</td>
</tr>
<tr>
<td><code>final void</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a>(Function1&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</code></div>
<p>Add a <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener to observe the loading state of the current <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>.</p>
</td>
</tr>
<tr>
<td><code>final @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a>&nbsp;T</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#getItem(kotlin.Int)">getItem</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;int&nbsp;index)</code></div>
<p>Get the item from the current PagedList at the specified index.</p>
</td>
</tr>
<tr>
<td><code>final @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a>&nbsp;T</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#peek(kotlin.Int)">peek</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;int&nbsp;index)</code></div>
<p>Returns the presented item at the specified position, without notifying Paging of the item access that would normally trigger page loads.</p>
</td>
</tr>
<tr>
<td><code>final void</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a>()</code></div>
<p>Refresh the data presented by this <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
</td>
</tr>
<tr>
<td><code>final @<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;void</code></td>
<td width="100%">
<div><code><span><del><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</a></del></span>(Function1&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</code></div>
<p><strong>This method is deprecated.</strong> dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</p>
</td>
</tr>
<tr>
<td><code>final void</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a>(Function1&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</code></div>
<p>Remove a previously registered <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener.</p>
</td>
</tr>
<tr>
<td><code>final void</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#retry()">retry</a>()</code></div>
<p>Retry any failed load requests that would result in a <code><a href="/reference/androidx/paging/LoadState.Error.html">LoadState.Error</a></code> update to this <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
</td>
</tr>
<tr>
<td><code>final <a href="/reference/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a>&lt;T&gt;</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#snapshot()">snapshot</a>()</code></div>
<p>Returns a new <code><a href="/reference/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a></code> representing the currently presented items, including any placeholders if they are enabled.</p>
</td>
</tr>
<tr>
<td><code>final void</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a>(<a href="/reference/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;&nbsp;pagingData)</code></div>
<p>Present a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> until it is invalidated by a call to <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> or <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">PagingSource.invalidate</a></code>.</p>
</td>
</tr>
<tr>
<td><code>final void</code></td>
<td width="100%">
<div><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(,androidx.paging.PagingData)">submitData</a>(<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&nbsp;lifecycle,&nbsp;<a href="/reference/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;&nbsp;pagingData)</code></div>
<p>Present a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> until it is either invalidated or another call to <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> is made.</p>
</td>
</tr>
</tbody>
</table>
</div>
<h2>Public fields</h2>
<div><a name="getDataRefreshFlow()"></a><a name="setDataRefreshFlow()"></a><a name="getDataRefreshFlow--"></a><a name="setDataRefreshFlow--"></a>
<h3 class="api-name" id="dataRefreshFlow()">dataRefreshFlow</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>public&nbsp;final&nbsp;@<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>&gt;&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#dataRefreshFlow()">dataRefreshFlow</a></pre>
<aside class="caution"><strong>This field is deprecated.</strong><br>dataRefreshFlow is now redundant with the information passed from loadStateFlow and getItemCount, and will be removed in a future alpha version</aside>
<p>A <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> of <code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a></code> that is emitted when new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> generations are submitted and displayed. The <code><a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-boolean/index.html">Boolean</a></code> that is emitted is <code>true</code> if the new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> is empty, <code>false</code> otherwise.</p>
</div>
<div><a name="getItemCount()"></a><a name="setItemCount()"></a><a name="getItemCount--"></a><a name="setItemCount--"></a>
<h3 class="api-name" id="itemCount()">itemCount</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;int&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a></pre>
<p>Get the number of items currently presented by this Differ. This value can be directly returned to <a href="[androidx.recyclerview.widget.RecyclerView.Adapter.getItemCount]">androidx.recyclerview.widget.RecyclerView.Adapter.getItemCount</a>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>int</code></td>
<td width="100%">
<p>Number of items being presented.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getLoadStateFlow()"></a><a name="setLoadStateFlow()"></a><a name="getLoadStateFlow--"></a><a name="setLoadStateFlow--"></a>
<h3 class="api-name" id="loadStateFlow()">loadStateFlow</h3>
<pre class="api-signature no-pretty-print">@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-opt-in/index.html">OptIn</a>(markerClass&nbsp;=&nbsp;[FlowPreview])<br>public&nbsp;final&nbsp;@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-opt-in/index.html">OptIn</a>(markerClass&nbsp;=&nbsp;[FlowPreview])&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a>&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>&gt;&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#loadStateFlow()">loadStateFlow</a></pre>
<p>A hot <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> of <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> that emits a snapshot whenever the loading state of the current <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> changes.</p>
<p>This flow is conflated, so it buffers the last update to <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> and immediately delivers the current load states on collection.</p>
</div>
<h2>Public constructors</h2>
<div><a name="AsyncPagingDataDiffer(, , kotlinx.coroutines.CoroutineDispatcher, kotlinx.coroutines.CoroutineDispatcher)"></a><a name="AsyncPagingDataDiffer---kotlinx.coroutines.CoroutineDispatcher-kotlinx.coroutines.CoroutineDispatcher-"></a>
<h3 class="api-name" id="AsyncPagingDataDiffer(,,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)">AsyncPagingDataDiffer</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;&lt;T&nbsp;extends&nbsp;<a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>&gt; <a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#AsyncPagingDataDiffer(,,kotlinx.coroutines.CoroutineDispatcher,kotlinx.coroutines.CoroutineDispatcher)">AsyncPagingDataDiffer</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&lt;T&gt;&nbsp;diffCallback,<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&nbsp;updateCallback,<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a>&nbsp;mainDispatcher,<br>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a>&nbsp;workerDispatcher<br>)</pre>
</div>
<h2>Public methods</h2>
<div><a name="addDataRefreshListener-kotlin.Function1-"></a>
<h3 class="api-name" id="addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>public&nbsp;final&nbsp;@<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;void&nbsp;<span><del><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</a></del></span>(Function1&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</pre>
<aside class="caution"><strong>This method is deprecated.</strong><br>dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</aside>
<p>Add a listener to observe new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> generations.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Function1&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener</code></td>
<td width="100%">
<p>called whenever a new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> is submitted and displayed. <code>true</code> is passed to the <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#listener()">listener</a></code> if the new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> is empty, <code>false</code> otherwise.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="addLoadStateListener-kotlin.Function1-"></a>
<h3 class="api-name" id="addLoadStateListener(kotlin.Function1)">addLoadStateListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a>(Function1&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</pre>
<p>Add a <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener to observe the loading state of the current <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>.</p>
<p>As new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> generations are submitted and displayed, the listener will be notified to reflect the current <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Function1&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener</code></td>
<td width="100%">
<p><code><a href="/reference/androidx/paging/LoadStates.html">LoadStates</a></code> listener to receive updates.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="getItem-kotlin.Int-"></a>
<h3 class="api-name" id="getItem(kotlin.Int)">getItem</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a><br>public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a>&nbsp;T&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#getItem(kotlin.Int)">getItem</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;int&nbsp;index)</pre>
<p>Get the item from the current PagedList at the specified index.</p>
<p>Note that this operates on both loaded items and null padding within the PagedList.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a>&nbsp;T</code></td>
<td width="100%">
<p>The item, or <code>null</code>, if a <code>null</code> placeholder is at the specified position.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;int&nbsp;index</code></td>
<td width="100%">
<p>Index of item to get, must be &gt;= 0, and &lt; <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#itemCount()">itemCount</a></code></p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="peek-kotlin.Int-"></a>
<h3 class="api-name" id="peek(kotlin.Int)">peek</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a><br>public&nbsp;final&nbsp;@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a>&nbsp;T&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#peek(kotlin.Int)">peek</a>(@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;int&nbsp;index)</pre>
<p>Returns the presented item at the specified position, without notifying Paging of the item access that would normally trigger page loads.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Returns</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a>&nbsp;T</code></td>
<td width="100%">
<p>The presented item at position <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#index()">index</a></code>, <code>null</code> if it is a placeholder</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>@<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/-int-range/index.html">IntRange</a>&nbsp;int&nbsp;index</code></td>
<td width="100%">
<p>Index of the presented item to return, including placeholders.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="refresh--"></a>
<h3 class="api-name" id="refresh()">refresh</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a>()</pre>
<p>Refresh the data presented by this <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
<p><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> triggers the creation of a new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> with a new instance of <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code> to represent an updated snapshot of the backing dataset. If a <code><a href="/reference/androidx/paging/RemoteMediator.html">RemoteMediator</a></code> is set, calling <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> will also trigger a call to <code><a href="/reference/androidx/paging/RemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">RemoteMediator.load</a></code> with <code><a href="/reference/androidx/paging/LoadType.REFRESH.html">LoadType</a></code> to allow <code><a href="/reference/androidx/paging/RemoteMediator.html">RemoteMediator</a></code> to check for updates to the dataset backing <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>.</p>
<p>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 <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">PagingSource.invalidate</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">invalidate</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="removeDataRefreshListener-kotlin.Function1-"></a>
<h3 class="api-name" id="removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</h3>
<pre class="api-signature no-pretty-print">@<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a><br>public&nbsp;final&nbsp;@<a href="/reference/androidx/paging/ExperimentalPagingApi.html">ExperimentalPagingApi</a>&nbsp;void&nbsp;<span><del><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#removeDataRefreshListener(kotlin.Function1)">removeDataRefreshListener</a></del></span>(Function1&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</pre>
<aside class="caution"><strong>This method is deprecated.</strong><br>dataRefreshListener is now redundant with the information passed from loadStateListener and getItemCount, and will be removed in a future alpha version</aside>
<p>Remove a previously registered listener for new <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> generations.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Function1&lt;<a href="https://developer.android.com/reference/java/lang/Boolean.html">Boolean</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener</code></td>
<td width="100%">
<p>Previously registered listener.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#addDataRefreshListener(kotlin.Function1)">addDataRefreshListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="removeLoadStateListener-kotlin.Function1-"></a>
<h3 class="api-name" id="removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#removeLoadStateListener(kotlin.Function1)">removeLoadStateListener</a>(Function1&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener)</pre>
<p>Remove a previously registered <code><a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a></code> listener.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">Parameters</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>Function1&lt;<a href="/reference/androidx/paging/CombinedLoadStates.html">CombinedLoadStates</a>,&nbsp;<a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html">Unit</a>&gt;&nbsp;listener</code></td>
<td width="100%">
<p>Previously registered listener.</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#addLoadStateListener(kotlin.Function1)">addLoadStateListener</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="retry--"></a>
<h3 class="api-name" id="retry()">retry</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#retry()">retry</a>()</pre>
<p>Retry any failed load requests that would result in a <code><a href="/reference/androidx/paging/LoadState.Error.html">LoadState.Error</a></code> update to this <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html">AsyncPagingDataDiffer</a></code>.</p>
<p>Unlike <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code>, this does not invalidate <code><a href="/reference/androidx/paging/PagingSource.html">PagingSource</a></code>, it only retries failed loads within the same generation of <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>.</p>
<p><code><a href="/reference/androidx/paging/LoadState.Error.html">LoadState.Error</a></code> can be generated from two types of load requests:</p>
<ul>
<li>
<p><code><a href="/reference/androidx/paging/PagingSource.html#load(androidx.paging.PagingSource.LoadParams)">PagingSource.load</a></code> returning <code><a href="/reference/androidx/paging/PagingSource.LoadResult.Error.html">PagingSource.LoadResult.Error</a></code></p>
</li>
<li>
<p><code><a href="/reference/androidx/paging/RemoteMediator.html#load(androidx.paging.LoadType,androidx.paging.PagingState)">RemoteMediator.load</a></code> returning <code><a href="/reference/androidx/paging/RemoteMediator.MediatorResult.Error.html">RemoteMediator.MediatorResult.Error</a></code></p>
</li>
</ul>
</div>
<div><a name="snapshot--"></a>
<h3 class="api-name" id="snapshot()">snapshot</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;<a href="/reference/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a>&lt;T&gt;&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#snapshot()">snapshot</a>()</pre>
<p>Returns a new <code><a href="/reference/androidx/paging/ItemSnapshotList.html">ItemSnapshotList</a></code> representing the currently presented items, including any placeholders if they are enabled.</p>
</div>
<div><a name="submitData-androidx.paging.PagingData-"></a>
<h3 class="api-name" id="submitData(androidx.paging.PagingData)">submitData</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a>(<a href="/reference/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;&nbsp;pagingData)</pre>
<p>Present a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> until it is invalidated by a call to <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#refresh()">refresh</a></code> or <code><a href="/reference/androidx/paging/PagingSource.html#invalidate()">PagingSource.invalidate</a></code>.</p>
<p><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> should be called on the same <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-dispatcher/index.html">CoroutineDispatcher</a></code> where updates will be dispatched to UI, typically <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-dispatchers/-main.html">Dispatchers.Main</a></code>. (this is done for you if you use <code>lifecycleScope.launch {}</code>).</p>
<p>This method is typically used when collecting from a <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> produced by <code><a href="/reference/androidx/paging/Pager.html">Pager</a></code>. For RxJava or LiveData support, use the non-suspending overload of <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code>, which accepts a <a href="[Lifecycle]">Lifecycle</a>.</p>
<p>Note: This method suspends while it is actively presenting page loads from a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code>, until the <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> is invalidated. Although cancellation will propagate to this call automatically, collecting from a <code><a href="/reference/androidx/paging/Pager.html#flow()">Pager.flow</a></code> with the intention of presenting the most up-to-date representation of your backing dataset should typically be done using <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/index.html">collectLatest</a></code>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/Pager.html">Pager</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
<div><a name="submitData(, androidx.paging.PagingData)"></a><a name="submitData--androidx.paging.PagingData-"></a>
<h3 class="api-name" id="submitData(,androidx.paging.PagingData)">submitData</h3>
<pre class="api-signature no-pretty-print">public&nbsp;final&nbsp;void&nbsp;<a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(,androidx.paging.PagingData)">submitData</a>(<a href="/reference/[JVM root]/&lt;ERROR CLASS&gt;.html">&lt;ERROR CLASS&gt;</a>&nbsp;lifecycle,&nbsp;<a href="/reference/androidx/paging/PagingData.html">PagingData</a>&lt;T&gt;&nbsp;pagingData)</pre>
<p>Present a <code><a href="/reference/androidx/paging/PagingData.html">PagingData</a></code> until it is either invalidated or another call to <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code> is made.</p>
<p>This method is typically used when observing a RxJava or LiveData stream produced by <code><a href="/reference/androidx/paging/Pager.html">Pager</a></code>. For <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.flow/-flow/index.html">Flow</a></code> support, use the suspending overload of <code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code>, which automates cancellation via <code><a href="https://kotlin.github.io/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines/-coroutine-scope/index.html">CoroutineScope</a></code> instead of relying of <a href="[Lifecycle]">Lifecycle</a>.</p>
<div class="devsite-table-wrapper">
<table class="responsive">
<thead>
<tr>
<th colspan="2">See also</th>
</tr>
</thead>
<tbody>
<tr>
<td><code><a href="/reference/androidx/paging/AsyncPagingDataDiffer.html#submitData(androidx.paging.PagingData)">submitData</a></code></td>
<td width="100%"></td>
</tr>
<tr>
<td><code><a href="/reference/androidx/paging/Pager.html">Pager</a></code></td>
<td width="100%"></td>
</tr>
</tbody>
</table>
</div>
</div>
</body>
</html>