| <html devsite="true"> |
| <head> |
| <title>PageKeyedDataSource.LoadCallback</title> |
| {% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <h1>PageKeyedDataSource.LoadCallback</h1> |
| {% setvar page_path %}androidx/paging/PageKeyedDataSource.LoadCallback.html{% endsetvar %} |
| {% setvar can_switch %}1{% endsetvar %} |
| {% include "reference/_java_switcher2.md" %} |
| <p> |
| <pre>public abstract class PageKeyedDataSource.LoadCallback<Key extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>, Value extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>></pre> |
| </p> |
| <hr> |
| <p>Callback for <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)">loadBefore</a></code> and <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)">loadAfter</a></code> to return data.</p> |
| <p>A callback can be called only once, and will throw if called again.</p> |
| <p>It is always valid for a DataSource loading method that takes a callback to stash the callback and call it later. This enables DataSources to be fully asynchronous, and to handle temporary, recoverable error states (such as a network error that can be retried).</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><Key extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of data used to query pages.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><Value extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of items being loaded.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <h2>Summary</h2> |
| <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><Key extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>, Value extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PageKeyedDataSource.LoadCallback.html#LoadCallback()">LoadCallback</a>()</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>abstract void</code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/androidx/paging/PageKeyedDataSource.LoadCallback.html#onResult(kotlin.collections.List,kotlin.Any)">onResult</a>(<a href="https://developer.android.com/reference/java/util/List.html">List</a><Value> data, @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> Key adjacentPageKey)</code></div> |
| <p>Called to pass loaded data from a <code><a href="/reference/androidx/paging/DataSource.html">DataSource</a></code>.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <h2>Public constructors</h2> |
| <div><a name="LoadCallback--"></a> |
| <h3 class="api-name" id="LoadCallback()">LoadCallback</h3> |
| <pre class="api-signature no-pretty-print">public final <Key extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>, Value extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>> <a href="/reference/androidx/paging/PageKeyedDataSource.LoadCallback.html#LoadCallback()">LoadCallback</a>()</pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><Key extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of data used to query pages.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code><Value extends @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> <a href="https://developer.android.com/reference/java/lang/Object.html">Object</a>></code></td> |
| <td width="100%"> |
| <p>Type of items being loaded.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <h2>Public methods</h2> |
| <div><a name="onResult(kotlin.collections.List, kotlin.Any)"></a><a name="onResult-kotlin.collections.List-kotlin.Any-"></a> |
| <h3 class="api-name" id="onResult(kotlin.collections.List,kotlin.Any)">onResult</h3> |
| <pre class="api-signature no-pretty-print">public abstract void <a href="/reference/androidx/paging/PageKeyedDataSource.LoadCallback.html#onResult(kotlin.collections.List,kotlin.Any)">onResult</a>(<a href="https://developer.android.com/reference/java/util/List.html">List</a><Value> data, @<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> Key adjacentPageKey)</pre> |
| <p>Called to pass loaded data from a <code><a href="/reference/androidx/paging/DataSource.html">DataSource</a></code>.</p> |
| <p>Call this method from your PageKeyedDataSource's <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)">loadBefore</a></code> and <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)">loadAfter</a></code> methods to return data.</p> |
| <p>It is always valid to pass a different amount of data than what is requested. Pass an empty list if there is no more data to load.</p> |
| <p>Pass the key for the subsequent page to load to adjacentPageKey. For example, if you've loaded a page in <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)">loadBefore</a></code>, pass the key for the previous page, or <code>null</code> if the loaded page is the first. If in <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)">loadAfter</a></code>, pass the key for the next page, or <code>null</code> if the loaded page is the last.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code><a href="https://developer.android.com/reference/java/util/List.html">List</a><Value> data</code></td> |
| <td width="100%"> |
| <p>List of items loaded from the PageKeyedDataSource.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>@<a href="/reference/androidx/annotation/Nullable.html">Nullable</a> Key adjacentPageKey</code></td> |
| <td width="100%"> |
| <p>Key for subsequent page load (previous page in <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadBefore(androidx.paging.PageKeyedDataSource.LoadParams)">loadBefore</a></code> / next page in <code><a href="/reference/androidx/paging/PageKeyedDataSource.html#loadAfter(androidx.paging.PageKeyedDataSource.LoadParams)">loadAfter</a></code>), or <code>null</code> if there are no more pages to load in the current load direction.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </body> |
| </html> |