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.

Paginate.Callbacks.onLoadMore() method is invoking two times

See original GitHub issue

Hello @MarkoMilos,

First of all, thanks a lot for creating such a wonderful API for pagination. It works smooth for me. But this is having an issue, if invoking onLoadMore() method on activity onCreateView(), REST API is invoking two times. This is happening because of below code:

private final RecyclerView.OnScrollListener mOnScrollListener = new RecyclerView.OnScrollListener() { @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { checkEndOffset(); // Each time when list is scrolled check if end of the list is reached } };

Method RecyclerView.OnScrollListenervoid onScrolled (RecyclerView recyclerView, int dx, int dy): Source[https://developer.android.com/reference/android/support/v7/widget/RecyclerView.OnScrollListener.html#onScrolled(android.support.v7.widget.RecyclerView, int, int)] Callback method to be invoked when the RecyclerView has been scrolled. This will be called after the scroll has completed. This callback will also be called if visible item range changes after a layout calculation. In that case, dx and dy will be 0.

So could you please add some condition to prevent onScrolled() method invocation on view creation. This will be helpful.

Thanks, Chandan Kushwaha

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
daimonkorcommented, Mar 5, 2017

@ckushwaha207 Please write your decision, I catch double call onLoadMore too (using simple activity and recyclerview).

0reactions
MarkoMiloscommented, Sep 12, 2020

Cannot reproduce this and no example is provided 😦 Closing due to inactivity.

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Callbacks in Paging library called multiple times
Unfortunatelly when new updates are called from the api, it is being called 4 or more times, even with boolean flags in the...
Read more >
Offset-based pagination - Apollo GraphQL Docs
This defines a merge function for the field that handles merging paginated results in the cache for you (see the source). Using with...
Read more >
Endless Scrolling with AdapterViews and RecyclerView
Inside the aforementioned onLoadMore method, load additional items into the adapter either by sending out a network request or by loading from another...
Read more >
Scroll Pull Bind and Paginate RecyclerView - Medium
create() for pagination. Invoke paginator.onNext(currentPage) when RecyclerView is scrolled to the bottom. This method resides inside presenter.onLoadMore(page: ...
Read more >
RecyclerView Pagination using Rxjava - Knowledge Transfer -
(if you have to do multiple things you have to coordinate all these callbacks); There's no real standard way to do an error...
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