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
0 answers

When I invalidate() my data, the onChanged submitList is triggered with 0 items before loadInitial gets the data from firebase

I am using the paging library with Firebase, and set ValueEventListener on the repository to invalidate the data whenever a change happens. The problem is as soon as I trigger invalidate(), the Observer trigger onChanged and…
1
vote
1 answer

Using Android Paging Library to display filtered results from same 2 loaded fragments in ViewPager with FragmentPagerAdapter

I have a single activity app which is centered around a fragment that will list data from online API. I use the same fragment throughout the app filtering the data as needed. Filtering is done by having parameters passed through the Factory to the…
Spaznuski
  • 45
  • 1
  • 6
1
vote
1 answer

How to invalidate subset of data in PagedList or DataSource?

In Android paging library, how do I invalidate the subset of the dataset in a PagedList or a DataSource? I write PagedList or DataSource because I don't know which one I should call. For example, I'm making a QA App called BufferOverflow. I have a…
aldok
  • 17,295
  • 5
  • 53
  • 64
1
vote
1 answer

Better way to change listId/query in data source paging

I can't find a better way to change listId of my VideosDataSource methods like load initial. I'm using view pager so it load 2 fragment at a time that's why i can't use getter/setter to set listId of my data source. here my data source class: class…
1
vote
0 answers

Android: Get current page Token from PageKeyedDataSource

I am using paging library (part of android jetpack), and override PageKeyedDataSource. This class have three methods ,and i have to get the current page Token but did not find any a way to get current page token. override fun loadInitial(params:…
Hussnain Haidar
  • 2,200
  • 19
  • 30
1
vote
2 answers

Positional DataSource doesn't load all data

I am trying to experiment with Positional DataSource. I have created the following dummy source. class ContactsDataSource : PositionalDataSource() { override fun loadRange(params: LoadRangeParams, callback: LoadRangeCallback)…
mallaudin
  • 4,744
  • 3
  • 36
  • 68
1
vote
0 answers

Invalidation of datasource PagedList Android

I need some insight on invalidation of datasource in a PagedList, like how it behaves and what should be done to attach a new datasource/PagedList. What I believe is that we cannot attach a new datasource, so do we need to attach a new PagedList to…
doomtrooper
  • 71
  • 1
  • 5
1
vote
0 answers

Android Paging Library - loadInitial() and loadAfter() running at the same time without scroll recyclerview

For example : PagedList.Config.Builder().setInitialLoadSizeHint(25).setPageSize(25). App loading initialData and load Additional Data at the same time. I have no idea how to fix it. Logs from console: D/OkHttp: --> GET…
1
vote
1 answer

Paging Library Invalidate Data Source

What's the simplest way to invalidate data retrieved by the paging library? I need to do that on logout. I've a DataSource.Factory and a DataSource that extends PageKeyedDataSource. Is it a good idea to call invalidate() on DataSource contructor?…
Jumpa
  • 4,319
  • 11
  • 52
  • 100
1
vote
1 answer

androidx.paging.PagedStorage.init is giving error when proguard is enabled

I'm using retrofit with okhttp and migrated to AndroidX, When I make a signed app that obfuscated with proguard it crashes and gives an error,but in debug mode when proguard is not enabled it's working good. and I disabled proguard just for testing…
user2682025
  • 656
  • 2
  • 13
  • 39
1
vote
5 answers

How to refresh data in a RecyclerView from a PagedListAdapter?

Using the following lines of code, I can to display data from a backend server in a RecyclerView using PagedListAdapter. movieViewModel = ViewModelProviders.of(this).get(MovieViewModel.class); MovieAdapter adapter = new…
1
vote
2 answers

Why would getItem in onBindViewHolder ever be null?

So, i'm trying to follow the paging library. and in most examples, they have something like: @Override public void onBindViewHolder(@NonNull PokemonViewHolder pokemonViewHolder, int i) { Pokemon pokemon = getItem(i); if (pokemon != null) {…
David T.
  • 22,301
  • 23
  • 71
  • 123
1
vote
0 answers

Android: how to add more data when list reached bottom when using PageKeyedDataSource with PagedList?

I have a RecyclerView with a PagedListAdapter which is used to show a list of text(such as 0,1,2,...,99), and there is a button to add 20 more items to database such that the list of text becomes (0,1,2,...,99,...,119). With page size equals to 20,…
1
vote
1 answer

Tell RecycerView to fetch more items programmatically?

I'm using a RecyclerView in conjunction with PagedListAdapter to fetch images from a rest API. The RecyclerView fetches more images as needed when I scroll through it. I would like to simulate scrolling very fast through the RecyclerView but still…
Isaac Perez
  • 570
  • 2
  • 15
  • 31
1
vote
2 answers

Inifinite Scroll Recycleview's imageview flickering when scroll

I'm showing images from server with Google Paging Library. When I show images from Localhost, it work perfect but with live server it's image is flickering. I tried to sleep Localhost for 2s to delay response but localhost's images were not…
mukeshsoni
  • 483
  • 8
  • 29