Created
May 30, 2017 08:31
-
-
Save EfeBudak/a099952e9890dfe5c2cb2c2c6c2d6291 to your computer and use it in GitHub Desktop.
Android Pagination with MVP
This file contains hidden or 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
mRecyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() { | |
@Override | |
public void onScrolled(RecyclerView recyclerView, int dx, int dy) { | |
super.onScrolled(recyclerView, dx, dy); | |
int visibleItemCount = recyclerView.getLayoutManager().getChildCount(); | |
int totalItemCount = recyclerView.getLayoutManager().getItemCount(); | |
int firstVisibleItemPosition = ((LinearLayoutManager) recyclerView.getLayoutManager()).findFirstVisibleItemPosition(); | |
if (!mSwipeRefreshLayout.isRefreshing() && !mEndOfList) { | |
if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount - Constants.PAGINATION_MARGIN | |
&& firstVisibleItemPosition >= 0 | |
&& totalItemCount >= Constants.PAGE_SIZE) { | |
mPresenter.onLoadNextPage(); | |
} | |
} | |
} | |
}); |
It depends on the number of items that you want to display. 30 - 40...
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
What is Constants.PAGE_SIZE here?