LivePagedListBuilder

public final class LivePagedListBuilder<Key extends Object, Value extends Object>


Builder for LiveData<PagedList> for Java users, given a androidx.paging.DataSource.Factory and a androidx.paging.PagedList.Config.

The required parameters are in the constructor, so you can simply construct and build, or optionally enable extra features (such as initial load key, or BoundaryCallback).

Parameters
<Key extends Object>

Type of input valued used to load data from the DataSource. Must be Int if you're using PositionalDataSource.

<Value extends Object>

Item type being presented.

See also
toLiveData

Summary

Public constructors

<Key extends Object, Value extends Object> LivePagedListBuilder(
    DataSource.Factory<Key, Value> dataSourceFactory,
    PagedList.Config config
)

Creates a LivePagedListBuilder with required parameters.

<Key extends Object, Value extends Object> LivePagedListBuilder(
    DataSource.Factory<Key, Value> dataSourceFactory,
    int pageSize
)

Creates a LivePagedListBuilder with required parameters.

<Key extends Object, Value extends Object> LivePagedListBuilder(
    Function0<PagingSource<Key, Value>> pagingSourceFactory,
    PagedList.Config config
)

Creates a LivePagedListBuilder with required parameters.

<Key extends Object, Value extends Object> LivePagedListBuilder(
    Function0<PagingSource<Key, Value>> pagingSourceFactory,
    int pageSize
)

Creates a LivePagedListBuilder with required parameters.

Public methods

final @NonNull LiveData<@NonNull PagedList<@NonNull Value>>

Constructs the LiveData<PagedList>.

final @NonNull LivePagedListBuilder<@NonNull Key, @NonNull Value>
setBoundaryCallback(
    PagedList.BoundaryCallback<Value> boundaryCallback
)

Sets a androidx.paging.PagedList.BoundaryCallback on each PagedList created, typically used to load additional data from network when paging from local storage.

final @NonNull LivePagedListBuilder<@NonNull Key, @NonNull Value>

Set the CoroutineScope that page loads should be launched within.

final @NonNull LivePagedListBuilder<@NonNull Key, @NonNull Value>
setFetchExecutor(Executor fetchExecutor)

Sets Executor used for background fetching of PagedLists, and the pages within.

final @NonNull LivePagedListBuilder<@NonNull Key, @NonNull Value>

First loading key passed to the first PagedList/DataSource.

Public constructors

LivePagedListBuilder

public final <Key extends Object, Value extends Object> LivePagedListBuilder(
    DataSource.Factory<Key, Value> dataSourceFactory,
    PagedList.Config config
)

Creates a LivePagedListBuilder with required parameters.

Parameters
DataSource.Factory<Key, Value> dataSourceFactory

DataSource factory providing DataSource generations.

PagedList.Config config

Paging configuration.

LivePagedListBuilder

public final <Key extends Object, Value extends Object> LivePagedListBuilder(
    DataSource.Factory<Key, Value> dataSourceFactory,
    int pageSize
)

Creates a LivePagedListBuilder with required parameters.

This method is a convenience for:

LivePagedListBuilder(dataSourceFactory,
new PagedList.Config.Builder().setPageSize(pageSize).build())
Parameters
DataSource.Factory<Key, Value> dataSourceFactory

DataSource.Factory providing DataSource generations.

int pageSize

Size of pages to load.

LivePagedListBuilder

public final <Key extends Object, Value extends Object> LivePagedListBuilder(
    Function0<PagingSource<Key, Value>> pagingSourceFactory,
    PagedList.Config config
)

Creates a LivePagedListBuilder with required parameters.

Parameters
Function0<PagingSource<Key, Value>> pagingSourceFactory

PagingSource factory providing PagingSource generations.

The returned PagingSource should invalidate itself if the snapshot is no longer valid. If a PagingSource becomes invalid, the only way to query more data is to create a new PagingSource by invoking the supplied pagingSourceFactory.

pagingSourceFactory will invoked to construct a new PagedList and PagingSource when the current PagingSource is invalidated, and pass the new PagedList through the LiveData<PagedList> to observers.

PagedList.Config config

Paging configuration.

LivePagedListBuilder

public final <Key extends Object, Value extends Object> LivePagedListBuilder(
    Function0<PagingSource<Key, Value>> pagingSourceFactory,
    int pageSize
)