Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public abstract class RecyclerViewOnScroll extends RecyclerView.OnScrollListener {
- @Override
- public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
- super.onScrolled(recyclerView, dx, dy);
- if ( dy > 0) {
- GridLayoutManager gridLayoutManager = (GridLayoutManager) recyclerView.getLayoutManager();
- int visibleItemCount = gridLayoutManager.getChildCount();
- int totalItemCount = gridLayoutManager.getItemCount();
- int firstVisibleItems = gridLayoutManager.findFirstVisibleItemPosition();
- if ((visibleItemCount + firstVisibleItems) >= totalItemCount) {
- loadMore();
- }
- }
- }
- protected abstract void loadMore();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement