Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"onLoadMore" method is passively invoked when the list which uses Paginate initializes #25

Open
Froyo91 opened this issue Jan 19, 2017 · 2 comments
Labels
triage In process of defining what kind of issue this is (bug, enhancement etc)

Comments

@Froyo91
Copy link

Froyo91 commented Jan 19, 2017

Thanks for your library, it is convenient for me to do pulling-up operations in my app.

However, I found that "onLoadMore" method is passively called in the case where the list which uses Paginate initializes. For example, when the list which is initialized only has two items so that it can not fill the phone screen, the onLoadMore method is invoked strangely. I read your source code, and I found some code in the EndScrollListener.java below:

@Override
    public void onScroll(AbsListView view, int firstVisibleItemPosition, int visibleItemCount, int totalItemCount) {
        if ((totalItemCount - visibleItemCount) <= (firstVisibleItemPosition + visibleThreshold)) {
            callback.onEndReached();
        }

        if (delegate != null) {
            delegate.onScroll(view, firstVisibleItemPosition, visibleItemCount, totalItemCount);
        }
    }

I found that "onEndReached is called" leads to my question. So I change the code above to this:

@Override
    public void onScroll(AbsListView view, int firstVisibleItemPosition, int visibleItemCount, int totalItemCount) {
        if (((totalItemCount - visibleItemCount) <= (firstVisibleItemPosition + visibleThreshold)) && (totalItemCount != visibleItemCount)) {
//        if (((totalItemCount - visibleItemCount) <= (firstVisibleItemPosition + visibleThreshold))) {
            callback.onEndReached();
        }

        if (delegate != null) {
            delegate.onScroll(view, firstVisibleItemPosition, visibleItemCount, totalItemCount);
        }
    }

I use this condition: totalItemCount != visibleItemCount

It seems my queestion has gone out after my change.

Could you please give some advice on my problem and my change on your code? Is my change on your code correct and is there any more efficient solution to solve my question? Please help and sorry for my poor English.If you are puzzled with my question, I will describe my question more detailedly afterwards.

@Morteza-Rastgoo
Copy link

Agree,
this instability on load more is wasting my time for about two days and no clue what to do :(

@MarkoMilos
Copy link
Owner

When onEndReached is called it will call the onLoadMore() method only if you indicate that loading is not currently in progress (by returning false from isLoading()) and that there is more data to load (by returning false from hasLoadedAllItems()). By doing so your are basically saying "I have more pages to load and I'm currently not loading anything" - so the library invokes onLoadMore()

Let me know if I misunderstood you. Also, can you c/p your initialization and callback code?

@MarkoMilos MarkoMilos added the triage In process of defining what kind of issue this is (bug, enhancement etc) label Sep 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage In process of defining what kind of issue this is (bug, enhancement etc)
Projects
None yet
Development

No branches or pull requests

3 participants