question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request: Android Paging Library support

See original GitHub issue

Is your feature request related to a problem? Please describe The Android Paging library is becoming the standard way to handle paging on Android. As far as I know, it currently does not work with Groupie yet. It would be great to add support for the library to Groupie.

@chibatching has written an article on how to connect the Paging library with Groupie. This is a great start, I’m not sure it’s the ideal solution:

  • It requires you to have a PagedList containing groupie Items. This is not a great separation of concern. We want the DataSource to provide data, not groupie Items to keep the DataSource free from any view related logic. The post suggests passing a transform function to the datasource, which works, but it still means that the ViewModel is exposing a PagedList of groupie items. You could transform the PagedList by using the .map function on the DataSourceFactory. However this means losing any additional information on the factory (such as a LiveData exposing error states).
  • It loads all content into a single Group. I’m not sure if this is a problem but ideally you’d submit the paged list directly into the adapter.
  • It’s not a native solution that the library provides

Describe the solution you’d like First-class support for the paging library in the main groupie library or perhaps an additional module.

Option 1

Add a update(p pagedList<T>, t TransformFunction) function to GroupAdapter.

This function takes a PagedList of any raw data, and a transform function that maps the data to groupie items.

Option 2

Add a update(p PagedList<T: Item>) function to GroupAdapter.

This still requires that the PagedList is mapped to groupie items by the consumer first.

Additional context If this is something you would consider adding to the library, I’d be happy to give it a shot and see if I can come up with a PR.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:18
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

9reactions
TylerMcCrawcommented, Mar 8, 2021

Paging 3 is api stable now. They have reached beta as of ~February 10. Could we start looking into this now? https://developer.android.com/jetpack/androidx/releases/paging#3.0.0-beta01

4reactions
HashirLabscommented, Apr 11, 2022

Any update by anyone on this please to support paging 3? If anyone has any fork for this, please message here

Read more comments on GitHub >

github_iconTop Results From Across the Web

Paging library overview - Android Developers
The Paging library helps you load and display pages of data from a larger dataset from local storage or over network.
Read more >
Paging 2 library overview - Android Developers
The Paging Library helps you load and display small chunks of data at a time. Loading partial data on demand reduces usage of...
Read more >
Paging - Android Developers
The Paging Library makes it easier for you to load data gradually and gracefully within your app's RecyclerView. This table lists all the...
Read more >
Page from network and database - Android Developers
RemoteMediator acts as a signal from the Paging library when the app has run out of cached data. You can use this signal...
Read more >
Load and display paged data - Android Developers
Use the PagingSource class directly to use Kotlin coroutines for async loading. The Paging library also provides classes to support other async ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found