public abstract class InfiniteScrollListener
extends RecyclerView.OnScrollListener
Constructor and Description |
---|
InfiniteScrollListener(int maxItemsPerRequest,
LinearLayoutManager layoutManager)
Initializes InfiniteScrollListener, which can be added
to RecyclerView with addOnScrollListener method
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
canLoadMoreItems()
Checks if more items can be loaded to the RecyclerView
|
void |
onScrolled(RecyclerView recyclerView,
int dx,
int dy)
Callback method to be invoked when the RecyclerView has been scrolled
|
abstract void |
onScrolledToEnd(int firstVisibleItemPosition)
Callback method to be invoked when the RecyclerView has been scrolled to the end
|
protected void |
refreshView(RecyclerView view,
RecyclerView.Adapter adapter,
int position)
Refreshes RecyclerView by setting new adapter,
calling invalidate method and scrolling to given position
|
public InfiniteScrollListener(int maxItemsPerRequest, LinearLayoutManager layoutManager)
maxItemsPerRequest
- Max items to be loaded in a single request.layoutManager
- LinearLayoutManager created in the Activity.public void onScrolled(RecyclerView recyclerView, int dx, int dy)
recyclerView
- The RecyclerView which scrolled.dx
- The amount of horizontal scroll.dy
- The amount of vertical scroll.protected void refreshView(RecyclerView view, RecyclerView.Adapter adapter, int position)
view
- RecyclerView to be refreshedadapter
- adapter with new list of items to be loadedposition
- position to which RecyclerView will be scrolledprotected boolean canLoadMoreItems()
public abstract void onScrolledToEnd(int firstVisibleItemPosition)
firstVisibleItemPosition
- Id of the first visible item on the list.