Android-Pagination-with-RecyclerView
Android-Pagination-with-RecyclerView copied to clipboard
Increasing TOTAL_PAGES stops scrolling
I tried increasing the value of TOTAL_PAGES in MainActivity to 15. When I run the App after making this change, the App does not scroll to 2nd page.
After "Movie 10", the progress bar is shown endless.
What am I missing?
Part 2 of my requirement is I don't want to fix the TOTAL_PAGES. It should be dynamic based on the amount of data I have in Database. I want to use the scrolling until I reach the last record from my Database query which is returned via API. How can I achieve this?
I also got the same problem. If I tried TOTAL_PAGES to 15 then the bottom progressbar always showing & I can't go to 2nd page. Did you find any solution?
I tried increasing the value of TOTAL_PAGES in MainActivity to 15. When I run the App after making this change, the App does not scroll to 2nd page.
After "Movie 10", the progress bar is shown endless.
What am I missing?
Part 2 of my requirement is I don't want to fix the TOTAL_PAGES. It should be dynamic based on the amount of data I have in Database. I want to use the scrolling until I reach the last record from my Database query which is returned via API. How can I achieve this?
Please get size of your array list and set to TOTAL_PAGES .
Class PaginationScrollListener edit as follows
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = layoutManager.getChildCount();
int totalItemCount = layoutManager.getItemCount();
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
if (!isLoading() && !isLastPage()) {
if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount
&& firstVisibleItemPosition >= 0) {
loadMoreItems();
}
}
}