| <html devsite="true"> |
| <head> |
| <title>PagingState</title> |
| {% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <h1>PagingState</h1> |
| {% setvar page_path %}androidx/paging/PagingState.html{% endsetvar %} |
| {% setvar can_switch %}1{% endsetvar %} |
| {% include "reference/_kotlin_switcher2.md" %} |
| <p> |
| <pre>class PagingState</pre> |
| </p> |
| <hr> |
| <p>Snapshot state of Paging system including the loaded <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code>, the last accessed <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code>, and the <code><a href="/reference/kotlin/androidx/paging/PagingState.html#config()">config</a></code> used.</p> |
| <h2>Summary</h2> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2"><h3>Public properties</h3></th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><a href="/reference/kotlin/kotlin/Int.html">Int</a>?</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code></div> |
| <p>Most recently accessed index in the list, including placeholders.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/PagingConfig.html">PagingConfig</a></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#config()">config</a></code></div> |
| <p><code><a href="/reference/kotlin/androidx/paging/PagingConfig.html">PagingConfig</a></code> that was given when initializing the <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> stream.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/kotlin/kotlin/collections/List.html">List</a><<a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a><Key, Value>></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code></div> |
| <p>Loaded pages of data in the list.</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><a href="/reference/kotlin/androidx/paging/PagingState.html#PagingState(kotlin.collections.List,kotlin.Int,androidx.paging.PagingConfig,kotlin.Int)">PagingState</a>(<br> pages: <a href="/reference/kotlin/kotlin/collections/List.html">List</a><<a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a><Key, Value>>,<br> anchorPosition: <a href="/reference/kotlin/kotlin/Int.html">Int</a>?,<br> config: <a href="/reference/kotlin/androidx/paging/PagingConfig.html">PagingConfig</a>,<br> @<a href="/reference/kotlin/kotlin/ranges/IntRange.html">IntRange</a> leadingPlaceholderCount: <a href="/reference/kotlin/kotlin/Int.html">Int</a><br>)</code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2"><h3>Public functions</h3></th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>Value?</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#closestItemToPosition(kotlin.Int)">closestItemToPosition</a>(anchorPosition: <a href="/reference/kotlin/kotlin/Int.html">Int</a>)</code></div> |
| <p>Coerces <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code> to closest loaded value in <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a><Key, Value>?</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#closestPageToPosition(kotlin.Int)">closestPageToPosition</a>(anchorPosition: <a href="/reference/kotlin/kotlin/Int.html">Int</a>)</code></div> |
| <p>Coerces an index in the list, including placeholders, to closest loaded page in <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code>.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>operator open <a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#equals(kotlin.Any)">equals</a>(other: <a href="/reference/kotlin/kotlin/Any.html">Any</a>?)</code></div> |
| </td> |
| </tr> |
| <tr> |
| <td><code>Value?</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#firstItemOrNull()">firstItemOrNull</a>()</code></div> |
| </td> |
| </tr> |
| <tr> |
| <td><code>open <a href="/reference/kotlin/kotlin/Int.html">Int</a></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#hashCode()">hashCode</a>()</code></div> |
| </td> |
| </tr> |
| <tr> |
| <td><code><a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#isEmpty()">isEmpty</a>()</code></div> |
| </td> |
| </tr> |
| <tr> |
| <td><code>Value?</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PagingState.html#lastItemOrNull()">lastItemOrNull</a>()</code></div> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <h2>Public properties</h2> |
| <div><a name="getAnchorPosition()"></a><a name="setAnchorPosition()"></a><a name="getAnchorPosition--"></a><a name="setAnchorPosition--"></a> |
| <h3 class="api-name" id="anchorPosition()">anchorPosition</h3> |
| <pre class="api-signature no-pretty-print">val <a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a>: <a href="/reference/kotlin/kotlin/Int.html">Int</a>?</pre> |
| <p>Most recently accessed index in the list, including placeholders.</p> |
| <p><code>null</code> if no access in the <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> has been made yet. E.g., if this snapshot was generated before or during the first load.</p> |
| </div> |
| <div><a name="getConfig()"></a><a name="setConfig()"></a><a name="getConfig--"></a><a name="setConfig--"></a> |
| <h3 class="api-name" id="config()">config</h3> |
| <pre class="api-signature no-pretty-print">val <a href="/reference/kotlin/androidx/paging/PagingState.html#config()">config</a>: <a href="/reference/kotlin/androidx/paging/PagingConfig.html">PagingConfig</a></pre> |
| <p><code><a href="/reference/kotlin/androidx/paging/PagingConfig.html">PagingConfig</a></code> that was given when initializing the <code><a href="/reference/kotlin/androidx/paging/PagingData.html">PagingData</a></code> stream.</p> |
| </div> |
| <div><a name="getPages()"></a><a name="setPages()"></a><a name="getPages--"></a><a name="setPages--"></a> |
| <h3 class="api-name" id="pages()">pages</h3> |
| <pre class="api-signature no-pretty-print">val <a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a>: <a href="/reference/kotlin/kotlin/collections/List.html">List</a><<a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a><Key, Value>></pre> |
| <p>Loaded pages of data in the list.</p> |
| </div> |
| <h2>Public constructors</h2> |
| <div><a name="PagingState(kotlin.collections.List, kotlin.Int, androidx.paging.PagingConfig, kotlin.Int)"></a><a name="PagingState-kotlin.collections.List-kotlin.Int-androidx.paging.PagingConfig-kotlin.Int-"></a> |
| <h3 class="api-name" id="PagingState(kotlin.collections.List,kotlin.Int,androidx.paging.PagingConfig,kotlin.Int)">PagingState</h3> |
| <pre class="api-signature no-pretty-print"><a href="/reference/kotlin/androidx/paging/PagingState.html#PagingState(kotlin.collections.List,kotlin.Int,androidx.paging.PagingConfig,kotlin.Int)">PagingState</a>(<br> pages: <a href="/reference/kotlin/kotlin/collections/List.html">List</a><<a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a><Key, Value>>,<br> anchorPosition: <a href="/reference/kotlin/kotlin/Int.html">Int</a>?,<br> config: <a href="/reference/kotlin/androidx/paging/PagingConfig.html">PagingConfig</a>,<br> @<a href="/reference/kotlin/kotlin/ranges/IntRange.html">IntRange</a> leadingPlaceholderCount: <a href="/reference/kotlin/kotlin/Int.html">Int</a><br>)</pre> |
| </div> |
| <h2>Public functions</h2> |
| <div><a name="closestItemToPosition-kotlin.Int-"></a> |
| <h3 class="api-name" id="closestItemToPosition(kotlin.Int)">closestItemToPosition</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/PagingState.html#closestItemToPosition(kotlin.Int)">closestItemToPosition</a>(anchorPosition: <a href="/reference/kotlin/kotlin/Int.html">Int</a>): Value?</pre> |
| <p>Coerces <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code> to closest loaded value in <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code>.</p> |
| <p>This function can be called with <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code> to fetch the loaded item that is closest to the last accessed index in the list.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Returns</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>Value?</code></td> |
| <td width="100%"> |
| <p>The closest loaded <code><a href="/reference/kotlin/androidx/paging/PagingState.html">Value</a></code> in <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code> to the provided <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code>. <code>null</code> if all loaded <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code> are empty.</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>anchorPosition</code></td> |
| <td width="100%"> |
| <p>Index in the list, including placeholders.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="closestPageToPosition-kotlin.Int-"></a> |
| <h3 class="api-name" id="closestPageToPosition(kotlin.Int)">closestPageToPosition</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/PagingState.html#closestPageToPosition(kotlin.Int)">closestPageToPosition</a>(anchorPosition: <a href="/reference/kotlin/kotlin/Int.html">Int</a>): <a href="/reference/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a><Key, Value>?</pre> |
| <p>Coerces an index in the list, including placeholders, to closest loaded page in <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code>.</p> |
| <p>This function can be called with <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code> to fetch the loaded page that is closest to the last accessed index in the list.</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/kotlin/androidx/paging/PagingSource.LoadResult.Page.html">PagingSource.LoadResult.Page</a><Key, Value>?</code></td> |
| <td width="100%"> |
| <p>The closest loaded <code><a href="/reference/kotlin/androidx/paging/PagingState.html">Value</a></code> in <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code> to the provided <code><a href="/reference/kotlin/androidx/paging/PagingState.html#anchorPosition()">anchorPosition</a></code>. <code>null</code> if all loaded <code><a href="/reference/kotlin/androidx/paging/PagingState.html#pages()">pages</a></code> are empty.</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>anchorPosition</code></td> |
| <td width="100%"> |
| <p>Index in the list, including placeholders.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="equals-kotlin.Any-"></a> |
| <h3 class="api-name" id="equals(kotlin.Any)">equals</h3> |
| <pre class="api-signature no-pretty-print">operator open fun <a href="/reference/kotlin/androidx/paging/PagingState.html#equals(kotlin.Any)">equals</a>(other: <a href="/reference/kotlin/kotlin/Any.html">Any</a>?): <a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></pre> |
| </div> |
| <div><a name="firstItemOrNull--"></a> |
| <h3 class="api-name" id="firstItemOrNull()">firstItemOrNull</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/PagingState.html#firstItemOrNull()">firstItemOrNull</a>(): Value?</pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Returns</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>Value?</code></td> |
| <td width="100%"> |
| <p>The first loaded item in the list or <code>null</code> if all loaded pages are empty or no pages were loaded when this <code><a href="/reference/kotlin/androidx/paging/PagingState.html">PagingState</a></code> was created.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="hashCode--"></a> |
| <h3 class="api-name" id="hashCode()">hashCode</h3> |
| <pre class="api-signature no-pretty-print">open fun <a href="/reference/kotlin/androidx/paging/PagingState.html#hashCode()">hashCode</a>(): <a href="/reference/kotlin/kotlin/Int.html">Int</a></pre> |
| </div> |
| <div><a name="isEmpty--"></a> |
| <h3 class="api-name" id="isEmpty()">isEmpty</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/PagingState.html#isEmpty()">isEmpty</a>(): <a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Returns</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><a href="/reference/kotlin/kotlin/Boolean.html">Boolean</a></code></td> |
| <td width="100%"> |
| <p><code>true</code> if all loaded pages are empty or no pages were loaded when this <code><a href="/reference/kotlin/androidx/paging/PagingState.html">PagingState</a></code> was created, <code>false</code> otherwise.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="lastItemOrNull--"></a> |
| <h3 class="api-name" id="lastItemOrNull()">lastItemOrNull</h3> |
| <pre class="api-signature no-pretty-print">fun <a href="/reference/kotlin/androidx/paging/PagingState.html#lastItemOrNull()">lastItemOrNull</a>(): Value?</pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Returns</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>Value?</code></td> |
| <td width="100%"> |
| <p>The last loaded item in the list or <code>null</code> if all loaded pages are empty or no pages were loaded when this <code><a href="/reference/kotlin/androidx/paging/PagingState.html">PagingState</a></code> was created.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </body> |
| </html> |