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
1
vote
1 answer

How to observe PagedList LiveData as it submit result asynchronously?

In the below code snippet, the PagedList LiveData observed only once. It successfully loads the next page to the recyclerView. As we know it internally use an asynchronous call to submit the result to the adapter. Question is how to observe…
Praful Ranjan
  • 117
  • 1
  • 2
  • 13
1
vote
1 answer

Android Paging Library - PositionalDataSource issue

I can get a total number of records from the server, so I am using PositionalDataSource for Network call. Everything works well but one problem: even if I don't scroll, the paging library continues fetching all the data from the server. How to solve…
sj.94
  • 123
  • 1
  • 5
1
vote
1 answer

Is it possible to use Paging (As part of android jetpack) without using Room DB?

Right now I'm working on an Android project which contains a RecyclerView with a large amount of data. For improving the app's performance I wish to implement the Paging component introduced in Android Jetpack. Since the project is pretty old, it…
1
vote
3 answers

How to observe LiveData with android paging in kotlin

I can't observe the LiveData change in activity, but the UI is updated(the list has grown in activty). I can only observe it once when the livedata is initialized. when the paging library call loadAfter method, the ui is updated, but…
Julius Wang
  • 361
  • 1
  • 6
  • 14
1
vote
0 answers

How to implement list with infinite scrolling in both direction with LiveData

I am trying to implement a list similar to "Schedule" view from Google calendar. Requirements are: The list should be infinitely scrollable in both vertical directions. The items should come from LiveData so the items can update themselves in the…
1
vote
2 answers

How to add item into PagingListAdpter when scroll to last position

How to add new item also different ViewType and show it on recyclerView when user scroll to the last position? I already fetch data from loadInitial and loadAfter. But I wondered How to add new item when the API send me the last item? For Example…
1
vote
1 answer

Incorrect Result from Room only pagination

I am using database only pagination to paginate chat heads from my db. There are around 450 enteries in my db @Query("select * from ChatHeadMaster where archive= :archive order by chatBot desc,lastMessageTimestamp desc") fun…
1
vote
1 answer

Does android paging library includes relatime updates like removing element from firestore?

If I use android paging library to paginate data from Firestore will the library include updates when items are deleted from Firestore. If document is deleted from firestore will it be deleted from RecyclerView? (Deletion of the document happens if…
Alen
  • 949
  • 3
  • 17
  • 37
1
vote
2 answers

How to add another data to items loaded by Paging Library?

I use Android Architecture Components to build my app. There is Paging Library to load items with Room generated DataSource. Also there is BoundaryCallback to get new data from server and store it in the database. It works fine, all is reactive,…
LIFED
  • 467
  • 1
  • 4
  • 16
1
vote
0 answers

Android pageKeyed datasource not getting called

I am trying to achieve paging in my app using android paging library.But I am stuck in one place. The dataSource is not getting created from the factory. Snippet below. private fun getLivePagedListBuilder(queryString: String):…
1
vote
1 answer

How to observe current page number in Paging library, when user scrolls up

Today I have implemented paging library in my app that uses TMDb api. Everything work nice, but I'm struggling with displaying current page. In DataSource class I have value: val currentPage = MutableLiveData() // Page => currentPage,…
1
vote
1 answer

What is ContiguousPagedList?

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…
erluxman
  • 18,155
  • 20
  • 92
  • 126
1
vote
0 answers

How to refresh a Pagedlist in android paging library?

I have a custom PositionalDataSource which loads data from Content Provider cursor. class FinalizedInstanceDataSource() : PositionalDataSource() { override fun loadRange(params: LoadRangeParams, callback:…
1
vote
0 answers

Use PagedList with Google Maps

I am implementing a Google Maps view that shows some points pinned in the viewport that the user map camera is. When the user moves the camera by dragging the map, the application must fetch new points in the new viewport and display it. I was…
Allan Veloso
  • 5,823
  • 1
  • 38
  • 36
1
vote
1 answer

Paging Library - Load Specific Page By Key

I'm using Android Paging Library, and probably don't use it 100% correct. I have a RecyclerView and a SnapHelper to basically implement a ViewPager. My pages are per date, e.g. 2019-03-21, so there can be infinite amount of pages. What I implemented…
Doron Sagi
  • 79
  • 1
  • 6