Skip to content

Instantly share code, notes, and snippets.

@lawloretienne
Last active February 22, 2017 06:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lawloretienne/fbbe579f0149948130193184c3ec85d9 to your computer and use it in GitHub Desktop.
Save lawloretienne/fbbe579f0149948130193184c3ec85d9 to your computer and use it in GitHub Desktop.
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
int visibleItemCount = recyclerView.getChildCount();
int totalItemCount = recyclerView.getAdapter().getItemCount();
int[] positions = layoutManager.findFirstVisibleItemPositions(null);
int firstVisibleItem = positions[1];
if (!isLoading && !isLastPage) {
if ((visibleItemCount + firstVisibleItem) >= totalItemCount && totalItemCount > 0) {
loadMoreItems();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment