PagedList.Builder

public final class PagedList.Builder<Key extends Object, Value extends Object>


Builder class for PagedList.

pagingSource, config, notifyDispatcher and fetchDispatcher must all be provided.

A PagedList queries initial data from its PagingSource during construction, to avoid empty PagedLists being presented to the UI when possible. It's preferred to present initial data, so that the UI doesn't show an empty list, or placeholders for a few frames, just before showing initial content.

LivePagedListBuilder does this creation on a background thread automatically, if you want to receive a LiveData<PagedList<...>>.

Parameters
<Key extends Object>

Type of key used to load data from the PagingSource.

<Value extends Object>

Type of items held and loaded by the PagedList.

Summary

Public constructors

<Key extends Object, Value extends Object> Builder(
    @NonNull DataSource<@NonNull Key, @NonNull Value> dataSource,
    @NonNull PagedList.Config config
)

Create a Builder with the provided DataSource and Config.

<Key extends Object, Value extends Object> Builder(
    @NonNull DataSource<@NonNull Key, @NonNull Value> dataSource,
    int pageSize
)

Create a PagedList.Builder with the provided DataSource and pageSize.

<Key extends Object, Value extends Object> Builder(
    @NonNull PagingSource<@NonNull Key, @NonNull Value> pagingSource,
    @NonNull PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value> initialPage,
    @NonNull PagedList.Config config
)

Create a PagedList.Builder with the provided PagingSource, initial PagingSource.LoadResult.Page, and PagedList.Config.

<Key extends Object, Value extends Object> Builder(
    @NonNull PagingSource<@NonNull Key, @NonNull Value> pagingSource,
    @NonNull PagingSource.LoadResult.Page<@NonNull Key, @NonNull Value> initialPage,
    int pageSize
)

Create a PagedList.Builder with the provided PagingSource, initial PagingSource.LoadResult.Page, and pageSize.

Public methods

final @NonNull PagedList<@NonNull Value>

Creates a PagedList with the given parameters.

final @NonNull PagedList.Builder<@NonNull Key, @NonNull Value>

The BoundaryCallback for out of data events.

final @NonNull PagedList.Builder<@NonNull Key, @NonNull Value>

Set the CoroutineScope that page loads should be launched within.

final @NonNull PagedList.Builder<@NonNull Key, @NonNull Value>

The CoroutineDispatcher used to fetch additional pages from the PagingSource.

final @NonNull PagedList.Builder<@NonNull Key, @NonNull Value>

This method is deprecated. Passing an executor will cause it get wrapped as a CoroutineDispatcher, consider passing a CoroutineDispatcher directly

final @NonNull PagedList.Builder<@NonNull Key, @NonNull Value>
setInitialKey(@Nullable Key initialKey)

Sets the initial key the PagingSource should load around as part of initialization.

final @NonNull PagedList.Builder<@NonNull Key, @NonNull Value>

The CoroutineDispatcher defining where page loading updates are dispatched.

final @NonNull PagedList.Builder<@NonNull Key, @NonNull Value>