I already tried to implement the endless scrolling for LinearLayoutManager and it is successful and tried to copy the LinearLayoutManager implementation to StaggeredGridLayoutManager but it doesn't work.
I just want to get the firstVisibleItem.
in LinearLayoutManager :
int firstVisibleItem = linearLayoutManager.findFirstVisibleItemPosition(int);
but in StaggeredGridLayoutManager is :
int firstVisibleItem = staggeredGridLayoutManager.findFirstVisibleItemPositions(int[])
How to get the firstVisibleItem using (int) not (int[])?
Is there any good approach/implementation about this?
Thanks in advance.
To implement EndlessRecyclerOnScrollListener first create EndlessRecyclerOnScrollListener java class
After into your activity or fragment (this example is for fragment) use the next code
This is my implementation of a
ScrollListener
.Here's my code for implementing the
ScrollListener
:Custom
ScrollListener
class:I got it working:
You can use one of two methods in the StaggeredGridLayoutManager:
findFirstVisibleItemPositions(int[])
findFirstCompletelyVisibleItemPositions(int[])
Pass an empty int array that will get initialized with the positions and use the one that makes sense for you.