Class EndlessScrollListener
-
- All Implemented Interfaces:
public final class EndlessScrollListener extends RecyclerView.OnScrollListener
Regular scroll listener which checks the layout manager of a recycler view and based on if the layout is reversed or not, it listens for scrolling gestures and triggers pagination when reaching the end top or end bottom of the list.
-
-
Constructor Summary
Constructors Constructor Description EndlessScrollListener(Integer loadMoreThreshold, Function0<Unit> loadMoreListener)
-
Method Summary
Modifier and Type Method Description UnitonScrolled(RecyclerView recyclerView, Integer dx, Integer dy)Whenever we scroll, if the pagination is enabled, we check the scroll direction and validity. UnitonScrollStateChanged(RecyclerView recyclerView, Integer newState)Handles scroll state changes where it waits for a state reset and new scroll gestures. final UnitenablePagination()Manually enables pagination in certain UI components and events. final UnitdisablePagination()Manually disables pagination in certain UI components and events. -
-
Constructor Detail
-
EndlessScrollListener
EndlessScrollListener(Integer loadMoreThreshold, Function0<Unit> loadMoreListener)
- Parameters:
loadMoreThreshold- The number of items or positions ahead of the end of the list where we can trigger the pagination.loadMoreListener- The handler which is called when pagination should be triggered.
-
-
Method Detail
-
onScrolled
Unit onScrolled(RecyclerView recyclerView, Integer dx, Integer dy)
Whenever we scroll, if the pagination is enabled, we check the scroll direction and validity.
-
onScrollStateChanged
Unit onScrollStateChanged(RecyclerView recyclerView, Integer newState)
Handles scroll state changes where it waits for a state reset and new scroll gestures.
-
enablePagination
final Unit enablePagination()
Manually enables pagination in certain UI components and events.
-
disablePagination
final Unit disablePagination()
Manually disables pagination in certain UI components and events.
-
-
-
-