PagedList.Config.Builder
public
static
final
class
PagedList.Config.Builder
extends Object
java.lang.Object | |
↳ | android.arch.paging.PagedList.Config.Builder |
Builder class for PagedList.Config
.
You must at minimum specify page size with setPageSize(int)
.
Summary
Public constructors | |
---|---|
PagedList.Config.Builder()
|
Public methods | |
---|---|
PagedList.Config
|
build()
Creates a |
PagedList.Config.Builder
|
setEnablePlaceholders(boolean enablePlaceholders)
Pass false to disable null placeholders in PagedLists using this Config. |
PagedList.Config.Builder
|
setInitialLoadSizeHint(int initialLoadSizeHint)
Defines how many items to load when first load occurs. |
PagedList.Config.Builder
|
setPageSize(int pageSize)
Defines the number of items loaded at once from the DataSource. |
PagedList.Config.Builder
|
setPrefetchDistance(int prefetchDistance)
Defines how far from the edge of loaded content an access must be to trigger further loading. |
Inherited methods | |
---|---|
Public constructors
PagedList.Config.Builder
PagedList.Config.Builder ()
Public methods
build
PagedList.Config build ()
Creates a PagedList.Config
with the given parameters.
Returns | |
---|---|
PagedList.Config |
A new Config. |
setEnablePlaceholders
PagedList.Config.Builder setEnablePlaceholders (boolean enablePlaceholders)
Pass false to disable null placeholders in PagedLists using this Config.
If not set, defaults to true.
A PagedList will present null placeholders for not-yet-loaded content if two conditions are met:
1) Its DataSource can count all unloaded items (so that the number of nulls to present is known).
2) placeholders are not disabled on the Config.
Call setEnablePlaceholders(false)
to ensure the receiver of the PagedList
(often a PagedListAdapter
) doesn't need to account for null items.
If placeholders are disabled, not-yet-loaded content will not be present in the list.
Paging will still occur, but as items are loaded or removed, they will be signaled
as inserts to the PagedList.Callback
.
onChanged(int, int)
will not be issued as part of loading,
though a PagedListAdapter
may still receive change events as a result of
PagedList diffing.
Parameters | |
---|---|
enablePlaceholders |
boolean : False if null placeholders should be disabled. |
Returns | |
---|---|
PagedList.Config.Builder |
this |
setInitialLoadSizeHint
PagedList.Config.Builder setInitialLoadSizeHint (int initialLoadSizeHint)
Defines how many items to load when first load occurs.
This value is typically larger than page size, so on first load data there's a large enough range of content loaded to cover small scrolls.
When using a PositionalDataSource
, the initial load size will be coerced to
an integer multiple of pageSize, to enable efficient tiling.
If not set, defaults to three times page size.
Parameters | |
---|---|
initialLoadSizeHint |
int : Number of items to load while initializing the PagedList. |
Returns | |
---|---|
PagedList.Config.Builder |
this |
setPageSize
PagedList.Config.Builder setPageSize (int pageSize)
Defines the number of items loaded at once from the DataSource.
Should be several times the number of visible items onscreen.
Configuring your page size depends on how your data is being loaded and used. Smaller page sizes improve memory usage, latency, and avoid GC churn. Larger pages generally improve loading throughput, to a point (avoid loading more than 2MB from SQLite at once, since it incurs extra cost).
If you're loading data for very large, social-media style cards that take up most of a screen, and your database isn't a bottleneck, 10-20 may make sense. If you're displaying dozens of items in a tiled grid, which can present items during a scroll much more quickly, consider closer to 100.
Parameters | |
---|---|
pageSize |
int : Number of items loaded at once from the DataSource. |
Returns | |
---|---|
PagedList.Config.Builder |
this |
setPrefetchDistance
PagedList.Config.Builder setPrefetchDistance (int prefetchDistance)
Defines how far from the edge of loaded content an access must be to trigger further loading.
Should be several times the number of visible items onscreen.
If not set, defaults to page size.
A value of 0 indicates that no list items will be loaded until they are specifically requested. This is generally not recommended, so that users don't observe a placeholder item (with placeholders) or end of list (without) while scrolling.
Parameters | |
---|---|
prefetchDistance |
int : Distance the PagedList should prefetch. |
Returns | |
---|---|
PagedList.Config.Builder |
this |
Interfaces
Classes
- AsyncPagedListDiffer
- DataSource
- DataSource.Factory
- ItemKeyedDataSource
- ItemKeyedDataSource.LoadCallback
- ItemKeyedDataSource.LoadInitialCallback
- ItemKeyedDataSource.LoadInitialParams
- ItemKeyedDataSource.LoadParams
- LivePagedListBuilder
- PagedList
- PagedList.BoundaryCallback
- PagedList.Builder
- PagedList.Callback
- PagedList.Config
- PagedList.Config.Builder
- PagedListAdapter
- PageKeyedDataSource
- PageKeyedDataSource.LoadCallback
- PageKeyedDataSource.LoadInitialCallback
- PageKeyedDataSource.LoadInitialParams
- PageKeyedDataSource.LoadParams
- PositionalDataSource
- PositionalDataSource.LoadInitialCallback
- PositionalDataSource.LoadInitialParams
- PositionalDataSource.LoadRangeCallback
- PositionalDataSource.LoadRangeParams
- RxPagedListBuilder