Android-Pagination-with-RecyclerView icon indicating copy to clipboard operation
Android-Pagination-with-RecyclerView copied to clipboard

Increasing TOTAL_PAGES stops scrolling

Open kamleshrao opened this issue 7 years ago • 3 comments

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?

kamleshrao avatar Sep 26 '18 07:09 kamleshrao

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?

saikat-bbil avatar Feb 05 '19 12:02 saikat-bbil

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 .

raiaslam avatar May 31 '19 11:05 raiaslam

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();
        }
    }

}

PhongDinh12 avatar Jan 20 '21 10:01 PhongDinh12