PositionalDataSource
abstract classPositionalDataSource<T : Any> : DataSource<Int, T>
kotlin.Any | ||
↳ | androidx.paging.DataSource<kotlin.Int, T> | |
↳ | androidx.paging.PositionalDataSource |
Position-based data loader for a fixed-size, countable data set, supporting fixed-size loads at arbitrary page positions.
Extend PositionalDataSource if you can load pages of a requested size at arbitrary positions, and provide a fixed item count. If your data source can't support loading arbitrary requested page sizes (e.g. when network page size constraints are only known at runtime), either use PageKeyedDataSource or ItemKeyedDataSource, or pass the initial result with the two parameter LoadInitialCallback.onResult.
Room can generate a Factory of PositionalDataSources for you:
@Dao interface UserDao { @Query("SELECT * FROM user ORDER BY age DESC") public abstract DataSource.Factory<Integer, User> loadUsersByAgeDesc(); }
Summary
Nested classes | |
---|---|
abstract |
Callback for loadInitial to return data, position, and count. |
open |
Holder object for inputs to loadInitial. |
abstract |
Callback for PositionalDataSource loadRange to return data. |
open |
Holder object for inputs to loadRange. |
Public constructors | |
---|---|
<init>() Position-based data loader for a fixed-size, countable data set, supporting fixed-size loads at arbitrary page positions. |
Public methods | |
---|---|
abstract Unit |
loadInitial(params: PositionalDataSource.LoadInitialParams, callback: PositionalDataSource.LoadInitialCallback<T>) Load initial list data. |
abstract Unit |
loadRange(params: PositionalDataSource.LoadRangeParams, callback: PositionalDataSource.LoadRangeCallback<T>) Called to load a range of data from the DataSource. |
PositionalDataSource<V> |
Applies the given function to each value emitted by the DataSource. |
PositionalDataSource<V> |
map(function: (T) -> V) Applies the given function to each value emitted by the DataSource. |
PositionalDataSource<V> |
Applies the given function to each value emitted by the DataSource. |
PositionalDataSource<V> |
Applies the given function to each value emitted by the DataSource. |
Inherited functions | |
---|---|
Inherited properties | |
---|---|
Public constructors
<init>
PositionalDataSource()
Position-based data loader for a fixed-size, countable data set, supporting fixed-size loads at arbitrary page positions.
Extend PositionalDataSource if you can load pages of a requested size at arbitrary positions, and provide a fixed item count. If your data source can't support loading arbitrary requested page sizes (e.g. when network page size constraints are only known at runtime), either use PageKeyedDataSource or ItemKeyedDataSource, or pass the initial result with the two parameter LoadInitialCallback.onResult.
Room can generate a Factory of PositionalDataSources for you:
@Dao interface UserDao { @Query("SELECT * FROM user ORDER BY age DESC") public abstract DataSource.Factory<Integer, User> loadUsersByAgeDesc(); }
Parameters | |
---|---|
T |
Type of items being loaded by the PositionalDataSource. |
Public methods
loadInitial
@WorkerThread abstract fun loadInitial(
params: PositionalDataSource.LoadInitialParams,
callback: PositionalDataSource.LoadInitialCallback<T>
): Unit
Load initial list data.
This method is called to load the initial page(s) from the DataSource.
LoadResult list must be a multiple of pageS