Back to project page octodroid.
The source code is released under:
MIT License
If you think the Android project octodroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.octodroid.views; //from w w w . j a v a2s. c o m import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; public abstract class MoreLoadScrollListener extends RecyclerView.OnScrollListener { int firstVisibleItem, visibleItemCount, totalItemCount; private int previousTotal = 0; private boolean loading = true; private int current_page = 1; private LinearLayoutManager mLinearLayoutManager; public MoreLoadScrollListener(LinearLayoutManager linearLayoutManager) { this.mLinearLayoutManager = linearLayoutManager; } @Override public void onScrolled(RecyclerView recyclerView, int dx, int dy) { super.onScrolled(recyclerView, dx, dy); visibleItemCount = recyclerView.getChildCount(); totalItemCount = mLinearLayoutManager.getItemCount(); firstVisibleItem = mLinearLayoutManager.findFirstVisibleItemPosition(); if (loading) { if (totalItemCount > previousTotal) { loading = false; previousTotal = totalItemCount; } } if (!loading && (totalItemCount - visibleItemCount) <= (firstVisibleItem)) {// + visibleThreshold)) { current_page++; onLoadMore(current_page); loading = true; } } public abstract void onLoadMore(int current_page); }