Android 12 Developer Preview is here! Try it out, and give us your feedback!

Builder

class Builder<Key : Any, Value : Any>
kotlin.Any
   ↳ androidx.paging.PagedList.Builder

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<...>>.

Summary

Public constructors
<init>(dataSource: DataSource<Key, Value>, config: PagedList.Config)

Create a Builder with the provided DataSource and Config.

<init>(dataSource: DataSource<Key, Value>, pageSize: Int)

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

<init>(pagingSource: PagingSource<Key, Value>, initialPage: PagingSource.LoadResult.Page<Key, Value>, config: PagedList.Config)

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

<init>(pagingSource: PagingSource<Key, Value>, initialPage: PagingSource.LoadResult.Page<Key, Value>, pageSize: Int)

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

Public methods
PagedList<Value>

Creates a PagedList with the given parameters.

PagedList.Builder<Key, Value>

The BoundaryCallback for out of data events.

PagedList.Builder<Key, Value>

Set the CoroutineScope that page loads should be launched within.

PagedList.Builder<Key, Value>

The CoroutineDispatcher used to fetch additional pages from the PagingSource.

PagedList.Builder<Key, Value>
setFetchExecutor(fetchExecutor: Executor)

The Executor used to fetch additional pages from the PagingSource.

PagedList.Builder<Key, Value>
setInitialKey(initialKey: Key?)

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

PagedList.Builder<Key, Value>

The CoroutineDispatcher defining where page loading updates are dispatched.

PagedList.Builder<Key, Value>
setNotifyExecutor(notifyExecutor: Executor)

The Executor defining where page loading updates are dispatched.

Public constructors

<init>

Builder(
    dataSource: DataSource<Key, Value>,
    config: PagedList.Config)

Create a Builder with the provided DataSource and Config.

Parameters
dataSource: DataSource<Key, Value> DataSource the PagedList will load from.
config: PagedList.Config PagedList.Config that defines how the PagedList loads data from its DataSource.

<init>

Builder(