Paging 3.0 Remarks
Paging 3.0 is a complete re-write of the library. It uses Kotlin, and it has first-class support for Kotlin coroutines and flow. It also has some new features. For example, it supports headers and footers, and it has retry and refresh mechanisms.
Some of the classes have changed names, and some functionality has changed as well. Here are a few examples:
-
PagedListAdapter has been renamed to
PagingDataAdapter
. The implementation is still the same.
-
DataSource has changed to
PagingSource
. ItemKeyedDataSource
, PageKeyedDataSource
and PositionalDataSource
have been merged to one PagingSource
class. And you no longer have to override loadInitial
, loadAfter
and loadBefore
. Instead, you have one load
method, which is a suspend
function. This means you don't need to use callbacks as before.
-
LivePagedListBuilder has changed to
Pager
. DataSource.Factory
is no longer required when creating a Pager
instance.
-
PagedList.Config has been renamed to
PagingConfig
, but its implementation remains the same.
This is a highlight of the major changes. You'll find a complete breakdown of changes, as well as information about backward compatibility, in the Paging 3 migration guide, Android Developers | Migrate to Paging 3.
Where to Go From Here?
Congratulations! You've learned how to use the Paging 3.0 library to manage infinitely scrolling lists. You've added headers and footers to your UI to make the list more accessible to the user. You've implemented caching to make your app usable when the network isn't available.
You can download the finished project by clicking the Download Materials button at the top or bottom of the tutorial.
In this tutorial, you've only scratched the surface of the Android Architecture Components and the Paging library. For more information, check out the official documentation at Android Developers | Library Overview.
We hope you enjoyed the tutorial. If you have any questions or comments, please join the forum discussion below.