Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Google Paging library not working

I'm trying to implement the google's paging library in my project. All things are already coded and network call is working in loadInitial() But it never goes in loadAfter(). As code structure is very complex I am not posting code directly here.

Here's the repository :

https://github.com/raghavsatyadev/PagingDemo

File link : https://github.com/raghavsatyadev/PagingDemo/blob/master/app/src/main/java/com/rocky/invmx/modules/order/OrdersActivity.java

like image 697
Raghav Satyadev Avatar asked Dec 04 '22 20:12

Raghav Satyadev


2 Answers

It is not an answer to the given question, but really similar problem.

In onBindViewHolder use getItem(int index) instead of getting item from currentList. As the accepted answer says - it is needed to call getItem to trigger loadAfter in DataSource.

like image 132
Janusz Hain Avatar answered Dec 06 '22 10:12

Janusz Hain


You are overriding getItem(int index) method in GenPagingRecyclerAdapter.java class without calling the super.getItem(index). If you look at the PagedListAdapter.java and dig into the method call you will see that this method internally calls the loadAfter method. So first the solution to your problem is to remove the getItem(int index) from GenPagingRecyclerAdapter.java class. Because you are not doing anything in it and if you really want to override getItem(int index) then call the super.getItem(int index) at start.

like image 26
waleedsarwar86 Avatar answered Dec 06 '22 09:12

waleedsarwar86