Last active
February 22, 2017 06:38
-
-
Save lawloretienne/fbbe579f0149948130193184c3ec85d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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