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
72
votes
4 answers

Paging library - Boundary callback for network + db with API taking page and size

Short question: What is the correct way to handle database + network on the Paging library from Architecture components, using an API that uses page + size to load a new page and the BoundaryCallback class? Research and explanation Currently the…
40
votes
3 answers

Paging Library Filter/Search

I am using the Android Paging Library like described here: https://developer.android.com/topic/libraries/architecture/paging.html But i also have an EditText for searching Users by Name. How can i filter the results from the Paging library to…
user3292244
  • 453
  • 1
  • 4
  • 8
28
votes
1 answer

Android paging library with clean architecture

I was trying the paging library from Android Architecture Component but I have doubts integrating it in a clean architecture based project. Generally I have 3 modules: Main Module (App) Data Module (Android module with network and db…
24
votes
11 answers

Keeping states of recyclerview in fragment with paging library and navigation architecture component

I'm using 2 components of the jetpack: Paging library and Navigation. In my case, I have 2 fragment: ListMoviesFragment & MovieDetailFragment when I scroll a certain distance and click a movie item of the recyclerview, MovieDetailFragment is…
22
votes
3 answers

Android Paging 3 - experiencing flickers, glitches or jumps in position when scrolling & loading new pages

Hello Guys im using Android Jetpack Paging library 3, I'm creating a news app that implements network + database scenario, and im following the codelab by google https://codelabs.developers.google.com/codelabs/android-paging , im doing it almost…
22
votes
5 answers

How to add date separators in recycler view using Paging Library?

After a lot of searching, I know its possible with regular adapter, but I have no idea how to do it using Paging Library. I don`t need code just a clue. Example
someguy234
  • 223
  • 2
  • 6
22
votes
2 answers

How to remove an item from PagedListAdapter in Android Paging Component

I used Paging with Retrofit to loading list of Notifications data from REST API. When I press delete button of a notification item then I call delete API to remove it. What is the proper way to remove it from PagedListAdapter after delete API…
22
votes
3 answers

How do I create a PagedList of an object for tests?

I have been working with the arch libraries from Google, but one thing that has made testing difficult is working with PagedList. For this example, I am using the repository pattern and returning details from either an API or network. So within…
22
votes
1 answer

How to transform items in a PagedList?(Android Arch Component Paging Library)

Android Architecture Component now introduced Paging Library, which is great. According to the official demo The DataSource.Factory now supports map and mapByPage methods, which means we may transform items in one DataSource. But DataSource and…
21
votes
4 answers

What is the correct way to check the data from a PagingData object in Android Unit Tests

I am using paging library to retrieve data from an api and show them in a list for this purpose in my repository I have created the method: fun getArticleList(query: String): Flow> in my viewmodel I have created the…
Cruces
  • 3,029
  • 1
  • 26
  • 55
21
votes
1 answer

Paging3: "Not sure how to convert a Cursor to this method's return type" when using PagingSource as return type in Room DAO

I was trying to imitate Google's codelab for the new Paging 3 library, and I encountered the following error when I tried to have a Room DAO method return a…
21
votes
6 answers

Paging library returns empty list initially

I'm using Paging library to paginate a list of items I'm retrieving from my server. Initially, when my fragment is loaded, it returns an empty list. But after changing fragments and going back to that fragment, I can see the list loaded. After…
21
votes
5 answers

How to stop blinking on recycler view with architecture components paging library

I have a chat-like activity where I am using a RecyclerView with a PagedListAdaper to load a bunch of messages. I'm using a PositionalDataSource to load the data. The loading it's self works fine but when I send a message, I invalidate my datasource…
20
votes
1 answer

How does Android Paging Library know to load more data?

Iʼm fairly new to developing Android apps and Iʼm trying to do everything “the right way.” So right now, Iʼm implementing the new Android Paging Library into my project, where I need to load a list of articles from a network server. I have an…
19
votes
3 answers

PagedListAdapter jumps to beginning of the list on receiving new PagedList

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…
1
2 3
34 35