I was looking into Android Paging
, and there seems to be a Concrete imprementation of PagedList
as ContiguousPagedList
. What's the use of this class? Looked to find it's usage / reason for existence but didn't find any. Can anyone explain why this ContiguousPagedList
exists?
ContiguousDataSource is used when a sequence of data is to be loaded one by one. Most of our use cases will be covered in this category.
As you mentioned, PageKeyedDataSource and ItemKeyedDataSource are the implementations of ContiguousDataSource.
ItemKeyedDataSource : Incremental data loader for paging keyed content, where loaded content uses previously loaded items as input to future loads.
PageKeyedDataSource: Incremental data loader for page-keyed content, where the requests will return keys for next/previous pages.
In both cases you need to use data from page N - 1 to load page N.
Non-ContiguousDataSource: Skip directly to a particular portion in the data set and load the stuff around this. E.g: Contacts app where you skip from ‘A’ to ‘H’.
Android Paging supports this feature as well, with the DataSource implementation of PositionalDataSource. This helps to load a fixed-size, countable data, supporting fixed-size loads at random page positions.