Difference between PagingDataAdapter and PagedListAdapter in Android Paging Libray Architecture Component

Viewed 2030

How do they work in the background?

I was a few familiar with the PagedListAdapter but not PagingDataAdapter(paging 3). What is the main usage of PagingDataAdapter and differ with PagedListAdapter

2 Answers

PagingDataAdapter is the Paging3 replacement for PagedListAdapter, it was rebuilt from the ground up to be Kotlin + Coroutines first, and supports synchronously reacting to LoadState + Errors (Paging2 didn't have these concepts built in), reactive transformations (including separators, LoadState-aware headers / footers via ConcatAdapter), and request de-duplication on top of a simplified API compared to Paging2.

To use PagingDataAdapter, it needs to hook up to the other Paging3 constructs via Pager, but all of these were built with backwards-compatibility with Paging2 in mind, so you can incrementally migrate from an existing project. e.g., Pager requires a () -> PagingSource<Key, Value>, but a DataSource.Factory.asPagingSourceFactory() exists for compatibility.

I highly recommend checking out:

If someone is migrating from Paging2 -> Paging3 and is searching like a madman for the toPagingSourceFactory() it's been renamed to asPagingSourceFactory() the docs don't reflect it yet.

Save yourself some digging and just use asPagingSourceFactory()

Related