Skip to content

Most visited

Recently visited

navigation

LivePagedListProvider

public abstract class LivePagedListProvider
extends Object

java.lang.Object
   ↳ android.arch.paging.LivePagedListProvider<Key, Value>


Provides a LiveData<PagedList>, given a means to construct a DataSource.

Return type for data-loading system of an application or library to produce a LiveData<PagedList>, while leaving the details of the paging mechanism up to the consumer.

If you're using Room, it can generate a LivePagedListProvider from a query:

 @Dao
 interface UserDao {
     @Query("SELECT * FROM user ORDER BY lastName ASC")
     public abstract LivePagedListProvider<Integer, User> usersByLastName();
 }
In the above sample, Integer is used because it is the Key type of TiledDataSource. Currently, Room can only generate a LIMIT/OFFSET, position based loader that uses TiledDataSource under the hood, and specifying Integer here lets you pass an initial loading position as an integer.

In the future, Room plans to offer other key types to support paging content with a KeyedDataSource.

See also:

Summary

Public constructors

LivePagedListProvider()

Public methods

LiveData<PagedList<Value>> create(Key initialLoadKey, PagedList.Config config)

Creates a LiveData of PagedLists, given the PagedList.Config.

LiveData<PagedList<Value>> create(Key initialLoadKey, int pageSize)

Creates a LiveData of PagedLists, given the page size.

Protected methods

abstract DataSource<Key, Value> createDataSource()

Construct a new data source to be wrapped in a new PagedList, which will be returned through the LiveData.

Inherited methods

From class java.lang.Object

Public constructors

LivePagedListProvider

LivePagedListProvider ()

Public methods

create

LiveData<PagedList<Value>> create (Key initialLoadKey, 
                PagedList.Config config)

Creates a LiveData of PagedLists, given the PagedList.Config.

This LiveData can be passed to a PagedListAdapter to be displayed with a RecyclerView.

Parameters
initialLoadKey Key: Initial key to pass to the data source to initialize data with.

config PagedList.Config: PagedList.Config to use with created PagedLists. This specifies how the lists will load data.

Returns
LiveData<PagedList<Value>> The LiveData of PagedLists.

create

LiveData<PagedList<Value>> create (Key initialLoadKey, 
                int pageSize)

Creates a LiveData of PagedLists, given the page size.

This LiveData can be passed to a PagedListAdapter to be displayed with a RecyclerView.

Parameters
initialLoadKey Key: Initial key used to load initial data from the data source.

pageSize int: Page size defining how many items are loaded from a data source at a time. Recommended to be multiple times the size of item displayed at once.

Returns
LiveData<PagedList<Value>> The LiveData of PagedLists.

Protected methods

createDataSource

DataSource<Key, Value> createDataSource ()

Construct a new data source to be wrapped in a new PagedList, which will be returned through the LiveData.

Returns
DataSource<Key, Value> The data source.

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience.
(Sep 2017 survey)