| <html devsite="true"> |
| <head> |
| <title>PositionalDataSource.LoadInitialCallback</title> |
| {% setvar book_path %}/reference/kotlin/androidx/_book.yaml{% endsetvar %} |
| {% include "_shared/_reference-head-tags.html" %} |
| </head> |
| <body> |
| <h1>PositionalDataSource.LoadInitialCallback</h1> |
| {% setvar page_path %}androidx/paging/PositionalDataSource.LoadInitialCallback.html{% endsetvar %} |
| {% setvar can_switch %}1{% endsetvar %} |
| {% include "reference/_kotlin_switcher2.md" %} |
| <p> |
| <pre>abstract class PositionalDataSource.LoadInitialCallback</pre> |
| </p> |
| <hr> |
| <p>Callback for <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.html#loadInitial(androidx.paging.PositionalDataSource.LoadInitialParams)">loadInitial</a></code> to return data, position, and count.</p> |
| <p>A callback should be called only once, and may 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>T</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><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#LoadInitialCallback()">LoadInitialCallback</a>()</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>abstract <a href="/reference/kotlin/kotlin/Unit.html">Unit</a></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#onResult(kotlin.collections.List,kotlin.Int,kotlin.Int)">onResult</a>(data: <a href="/reference/kotlin/kotlin/collections/List.html">List</a><T>, position: <a href="/reference/kotlin/kotlin/Int.html">Int</a>, totalCount: <a href="/reference/kotlin/kotlin/Int.html">Int</a>)</code></div> |
| <p>Called to pass initial load state from a DataSource.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>abstract <a href="/reference/kotlin/kotlin/Unit.html">Unit</a></code></td> |
| <td width="100%"> |
| <div><code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#onResult(kotlin.collections.List,kotlin.Int)">onResult</a>(data: <a href="/reference/kotlin/kotlin/collections/List.html">List</a><T>, position: <a href="/reference/kotlin/kotlin/Int.html">Int</a>)</code></div> |
| <p>Called to pass initial load state from a DataSource without total count, when placeholders aren't requested.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| <h2>Public constructors</h2> |
| <div><a name="LoadInitialCallback--"></a> |
| <h3 class="api-name" id="LoadInitialCallback()">LoadInitialCallback</h3> |
| <pre class="api-signature no-pretty-print"><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#LoadInitialCallback()">LoadInitialCallback</a>()</pre> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>T</code></td> |
| <td width="100%"> |
| <p>Type of items being loaded.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <h2>Public functions</h2> |
| <div><a name="onResult(kotlin.collections.List, kotlin.Int, kotlin.Int)"></a><a name="onResult-kotlin.collections.List-kotlin.Int-kotlin.Int-"></a> |
| <h3 class="api-name" id="onResult(kotlin.collections.List,kotlin.Int,kotlin.Int)">onResult</h3> |
| <pre class="api-signature no-pretty-print">abstract fun <a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#onResult(kotlin.collections.List,kotlin.Int,kotlin.Int)">onResult</a>(data: <a href="/reference/kotlin/kotlin/collections/List.html">List</a><T>, position: <a href="/reference/kotlin/kotlin/Int.html">Int</a>, totalCount: <a href="/reference/kotlin/kotlin/Int.html">Int</a>): <a href="/reference/kotlin/kotlin/Unit.html">Unit</a></pre> |
| <p>Called to pass initial load state from a DataSource.</p> |
| <p>Call this method from <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.html#loadInitial(androidx.paging.PositionalDataSource.LoadInitialParams)">loadInitial</a></code> function to return data, and inform how many placeholders should be shown before and after. If counting is cheap compute (for example, if a network load returns the information regardless), it's recommended to pass the total size to the totalCount parameter. If placeholders are not requested (when <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialParams.html#placeholdersEnabled()">LoadInitialParams.placeholdersEnabled</a></code> is false), you can instead call <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#onResult(kotlin.collections.List,kotlin.Int,kotlin.Int)">onResult</a></code>.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>data</code></td> |
| <td width="100%"> |
| <p>List of items loaded from the <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>. If this is empty, the <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code> is treated as empty, and no further loads will occur.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>position</code></td> |
| <td width="100%"> |
| <p>Position of the item at the front of the list. If there are N items before the items in data that can be loaded from this DataSource, pass N.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>totalCount</code></td> |
| <td width="100%"> |
| <p>Total number of items that may be returned from this DataSource. Includes the number in the initial <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#data()">data</a></code> parameter as well as any items that can be loaded in front or behind of <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#data()">data</a></code>.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| <div><a name="onResult(kotlin.collections.List, kotlin.Int)"></a><a name="onResult-kotlin.collections.List-kotlin.Int-"></a> |
| <h3 class="api-name" id="onResult(kotlin.collections.List,kotlin.Int)">onResult</h3> |
| <pre class="api-signature no-pretty-print">abstract fun <a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#onResult(kotlin.collections.List,kotlin.Int)">onResult</a>(data: <a href="/reference/kotlin/kotlin/collections/List.html">List</a><T>, position: <a href="/reference/kotlin/kotlin/Int.html">Int</a>): <a href="/reference/kotlin/kotlin/Unit.html">Unit</a></pre> |
| <p>Called to pass initial load state from a DataSource without total count, when placeholders aren't requested.</p> |
| <p><b>Note:</b> This method can only be called when placeholders are disabled (i.e., <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialParams.html#placeholdersEnabled()">LoadInitialParams.placeholdersEnabled</a></code> is <code>false</code>).</p> |
| <p>Call this method from <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.html#loadInitial(androidx.paging.PositionalDataSource.LoadInitialParams)">loadInitial</a></code> function to return data, if position is known but total size is not. If placeholders are requested, call the three parameter variant: <code><a href="/reference/kotlin/androidx/paging/PositionalDataSource.LoadInitialCallback.html#onResult(kotlin.collections.List,kotlin.Int,kotlin.Int)">onResult</a></code>.</p> |
| <div class="devsite-table-wrapper"> |
| <table class="responsive"> |
| <thead> |
| <tr> |
| <th colspan="2">Parameters</th> |
| </tr> |
| </thead> |
| <tbody> |
| <tr> |
| <td><code>data</code></td> |
| <td width="100%"> |
| <p>List of items loaded from the <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>. If this is empty, the <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code> is treated as empty, and no further loads will occur.</p> |
| </td> |
| </tr> |
| <tr> |
| <td><code>position</code></td> |
| <td width="100%"> |
| <p>Position of the item at the front of the list. If there are N items before the items in data that can be provided by this <code><a href="/reference/kotlin/androidx/paging/DataSource.html">DataSource</a></code>, pass N.</p> |
| </td> |
| </tr> |
| </tbody> |
| </table> |
| </div> |
| </div> |
| </body> |
| </html> |