Skip to content

Instantly share code, notes, and snippets.

@pwittchen
Created February 28, 2016 13:29
Show Gist options
  • Save pwittchen/add026064c6fa4c2b74d to your computer and use it in GitHub Desktop.
Save pwittchen/add026064c6fa4c2b74d to your computer and use it in GitHub Desktop.
private InfiniteScrollListener createInfiniteScrollListener() {
return new InfiniteScrollListener(maxItemsPerRequest, layoutManager) {
@Override public void onScrolledToEnd(final int firstVisibleItemPosition) {
// load your items here
// logic of loading items will be different depending on your specific use case
// when new items are loaded, combine old and new items, pass them to your adapter
// and call refreshView(...) method from InfiniteScrollListener class to refresh RecyclerView
refreshView(recyclerView, new MyAdapter(items), firstVisibleItemPosition);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment