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

Paging 3 Library: Combine results of 3 tables sequentially

I want to use Paging 3 Library and combine results from 3 tables such that: Result from Table1 are shown first. When Results from Table1 has reached end of their data then results from Table2 are shown. When results from Table2 have reached end of…
Cpp crusaders
  • 117
  • 2
  • 10
0
votes
0 answers

What is the best way to use LazyColumn with itemsIndexed in PagingData this is deprecated

What is the best way to use LazyColumn with itemsIndexed in PagingData this is deprecated deprecated code: val list = (state as State.Success).data.collectAsLazyPagingItems() LazyColumn( modifier = Modifier …
Rafael Souza
  • 1,143
  • 2
  • 13
  • 29
0
votes
1 answer

Scroll position of LazyColumn built with `collectAsLazyPagingItems` is lost when using Navigation

Scroll position of the lazy column is lost when navigating. val pageItems = myPager?.collectAsLazyPagingItems() LazyColumn(state = rememberLazyListState(), modifier = Modifier.padding(bottom = paddingValues.calculateBottomPadding())) { …
0
votes
1 answer

In Compose PagingData / LazyPagingItems returns 0 items and Loading state initially on Config Changes before returning data from cache

So I have this screen: @Composable fun ChatDetailsScreen( chatDetailsViewModel: ChatDetailsViewModel = hiltViewModel(), navigateUp: () -> Unit ) { val chatMessagesResponse =…
0
votes
0 answers

Map paging source from Room to domain entities

I have model in domain called ItemEntity and ItemRepositoy which have method to return PagingSource from database. I also have ItemRoomEntity in data layer. In ItemDao for this Room entity I have method which is returning…
0
votes
0 answers

Why jetpack compose room offline pagination not loading next page?

Dao class @Dao interface ShlokaDao { @Query("SELECT * FROM shlokas_table ORDER BY _Id ASC LIMIT :limit OFFSET :offset ") suspend fun getPagedShlokasList(limit: Int, offset: Int): List } Paging DataSource class…
0
votes
2 answers

How do I make my own Paging Source when using Remote Mediator in the Paging Library?

I am trying to make my own Paging Source, because the Paging Source provided by the Room library does not suit me. I ran into such a problem that Paging Source loads the first 1 or 2 pages of data (depending on whether Remote Mediator has time to…
0
votes
1 answer

Android: Paging with RemoteMediator keeps loading with load type PREPEND until scroll starts?

I am trying to implement paging using RemoteMediator. Now, the remote data source is a random dog image API, so the endpoint does not have pagination but instead returns a list of random dog image URLs each request. The RemoteMediator looks like…
0
votes
0 answers

IllegalArgumentException: page introduces incorrect tiling

I'm trying to load messages from database but consistently getting IllegalArgumentException, my data source looks like this @Override public void loadInitial(@NonNull LoadInitialParams params, @NonNull LoadInitialCallback
Muhammad Nadeem
  • 211
  • 2
  • 14
0
votes
1 answer

Where to place the ItemsPagingSource file in Android project MVVM?

I have an Android project where I use MVVM. This is the structure: src \_ domain \_ model \_ repository \_ ItemsRepository \_ data \_ repository \_ ItemsRepositoryImpl \_ presentations \_ items \_…
Joan P.
  • 2,368
  • 6
  • 30
  • 63
0
votes
0 answers

PagingDataAdapter keep shuffling items on scrolling

Items keeps shuffling while scrolling with PagingDataAdapter with Paging3 Below is ViewHolder DiffUtil callback, but it still changes items while scrolling companion object { private val diffUtil = object : DiffUtil.ItemCallback() { …
Sandeep Kumar
  • 168
  • 1
  • 9
0
votes
1 answer

How can I remember the list position in a Compose LazyColumn using Paging 3 LazyPagingItems?

I have a function like: @Composable fun LazyElementList(data: Flow>) { val scrollState = rememberLazyListState() val elements = data.collectAsLazyPagingItems() LazyColumn(state = scrollState) { …
Sean
  • 2,632
  • 2
  • 27
  • 35
0
votes
1 answer

Hide LaodingView when search have no result

I have implemented search functionality in my app which display result as a verticalGridView with pagination : https://github.com/alirezaeiii/TMDb-Compose I have following logic for refresh load state that works as I wish : @Composable fun
Ali
  • 9,800
  • 19
  • 72
  • 152
0
votes
1 answer

Android Paging 3 Codelabs failed on Room Paging

I am trying to follow this Paging 3 Codelab:https://developer.android.com/codelabs/android-paging, but when trying to compile at the end I am getting this error: RepoDao.java:17: error: To use PagingSource, you must add `room-paging` artifact from…
Alejandro Cumpa
  • 2,118
  • 1
  • 24
  • 45
0
votes
1 answer

Use different versions of paging library in the same project

How can I use paging 2 in one module and paging 3 in another module? Now I have paging 3 dependencies pulled into both modules
Денис
  • 75
  • 5