Questions tagged [android-paging]

The Paging Architecture Component makes it easier for your app to gradually load information as needed from a data source, without overloading the device or waiting too long for a big database query.

Overview:-

Many apps work with large sets of data, but only need to load and display a small portion of that data at any time. An app might have thousands of items that it could potentially display, but it might only need access to a few dozen of them at once. If the data is stored or synchronized with a remote database, this can also slow the app and waste the user's data plan

While existing Android APIs allowed for paging in content, they came with significant constraints and drawbacks:

  • CursorAdapter makes it easier to map database query results to ListView items.
  • AsyncListUtil allows for paging position-based data into a RecyclerView but doesn't allow for non-positional paging, and it forces nulls-as-placeholders in a countable data set.

Classes:-

The Paging Library provides the following classes, as well as additional supporting classes:

  • DataSource: Use this class to define a data source you need to pull paged data from.
  • PagedList: This class loads data from a DataSource. You can configure how much data is loaded at a time, and how much data should be prefetched, minimizing the amount of time your users have to wait for data to be loaded.
  • PagedListAdapter: This class is an implementation of RecyclerView.Adapter that presents data from a PagedList.
  • LivePagedListProvider: This class generates a LiveData from the DataSource you provide.
524 questions
11
votes
4 answers

Paging 3 initial loading not shown

I am working with paging 3, everything work fine except initial loading state. I am adding withLoadStateFooter but it never show loading state at first call Here is my implementation Load State Adapter class LoadStateAdapter ( private val retry:…
ysfcyln
  • 2,857
  • 6
  • 34
  • 61
11
votes
0 answers

Paging Library Callback.OnResult Not Returning Value To Livedata

I wanna to implement jetpack paging library. everything seems working, after getting response from api (using Retrofit2 and coroutine) android paging callback is calling his onResult interface. but it's not returning it's value to livedata in main…
11
votes
2 answers

After DataSource.Invalidate() new PagedList has only one page

I have a list with pagination which I implemented using Paging library. Items on this list can be modified (changed/deleted). According to official documentation, I'm first changing in-memory list cache from which my DataSource gets pages and after…
11
votes
1 answer

PageList.size is always zero

Actually, I am new to Paging Library. Here is situation, i'm observing PagedList from my ViewModel which is always returning zero even news list appeared on UI. viewModel.getNews().observe(this, news -> { …
11
votes
2 answers

How to use AAC paging library with list size different than list size returned by Room database

I'm trying to use the new Paging Library and Room as database but I'm facing a problem, the PagedList returned by the database is not supposed to be the same list sent to the UI, I map some entities before showing it to the user and during this map…
11
votes
4 answers

When using Paging Library, observer showing list size as zero

I am trying to use paging library with newer versions. I am using volley to fetch my data from network. Whenever I fetch data from network, the data is fetched but when the call goes to observer the list size shown there is zero. I am unsure what I…
Matrix
  • 147
  • 1
  • 7
11
votes
2 answers

Update list items in PagingLibrary w/o using Room (Network only)

I'm using Paging Library to load data from network using ItemKeyedDataSource. After fetching items user can edit them, this updates are done inside in Memory cache (no database like Room is used). Now since the PagedList itself cannot be updated…
10
votes
2 answers

Android Paging 3 how to filter, sort and search my data

I'm trying to implement paging I'm using Room and it took me ages to realize that its all done for me but what I need to do is be able to filter search and sort my data. I want to keep it as LiveData for now I can swap to flow later. I had this…
martinseal1987
  • 1,862
  • 8
  • 44
  • 77
10
votes
2 answers

How to check the list size or for empty list in Paging 3 library

I've been able to successfully implement the new alpha07 version of Paging 3 library by following the instructions available here: https://developer.android.com/topic/libraries/architecture/paging/v3-paged-data#guava-livedata However, now I am in…
Shadow
  • 4,168
  • 5
  • 41
  • 72
10
votes
1 answer

Android Jetpack Paging 3: PagingSource with Room

I'm using latest Jetpack libraries. Pagination3 version: 3.0.0-alpha05 Room Version : 2.3.0-alpha02 My entities have Long as PrimaryKey and Room can generate PagingSource for other than Int type. error: For now, Room only supports PagingSource with…
10
votes
2 answers

How can we get entire object list passes to the PagingDataAdapter while using Paging library 3.0?

I am new to the paging library 3.0, I need to paginate data only from the local database. Initially, I fetched PagingSource from the database and use it as flow. fun getChatMessages(chatWrapper: ChatWrapper):…
Anil Bhomi
  • 691
  • 7
  • 12
10
votes
2 answers

PageKeyedDataSource loadAfter called continuously

I have a PageKeyedDataSource that continuously calls the loadAfter, and all the items are added in the Recyclerview multiple times. From the API side a null lastEvaluatedKey means give me the first page which kinda makes sense on why it keeps…
Eliza Camber
  • 1,536
  • 1
  • 13
  • 21
10
votes
1 answer

How to add a header to a PagedList using Android Paging Library

I have tried adding a header the normal way (different view type, incrementing the data count by 1 etc.), but the paged list scroll bar jumps to the bottom of the list. I have since come across the AsyncPagedListDiffer and tried to implement it, but…
Daniel Wilson
  • 18,838
  • 12
  • 85
  • 135
10
votes
3 answers

Paging Library: How to reload portion of data on demand?

I use Paging Library to paginate my data set. What I'm trying to do is to refresh the RecyclerView after data in my database has been changed. I have this LiveData: val listItems: LiveData> = object : LivePagedListProvider
9
votes
1 answer

Paging 3 list auto refresh on navigation back in jetpack compose navigation

I am using Jetpack Compose, along with Paging 3 library & Jetpack Navigation. The issue I am facing is I have a LazyList which is fetching data from remote source using paging library. ViewModel fun getImages(): Flow> =…
1 2
3
34 35