Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between PagingDataAdapter and PagedListAdapter in Android Paging Libray Architecture Component

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

like image 343
Purple Blossom Avatar asked May 30 '26 05:05

Purple Blossom


1 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:

  • Codelab: https://codelabs.developers.google.com/codelabs/android-paging/index.html?index=..%2F..index
  • DAC: http://d.android.com/paging3
  • Android11 Video: https://www.youtube.com/watch?v=1cwqGOku2a4
like image 67
dlam Avatar answered Jun 01 '26 18:06

dlam



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!