I am implementing a Retrofit APi for getting data from the server and showing this in a RecyclerView
using the Litho framework, and it's doing well. As all of us know when we have infinite data to show in recyclerview we have to implement the pagination pattern. And I know this, but I am confused how to implement this in the Litho framework. Litho the provides onScrollListener()
method:
final Component component = Recycler.create(context)
.binder(recyclerBinder)
.onScrollListener(new RecyclerView.OnScrollListener() {
@Override
public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
super.onScrollStateChanged(recyclerView, newState);
//
}
@Override
public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
super.onScrolled(recyclerView, dx, dy);
//
})
.build();
I don't know: how to use a customized EndlessRecyclerViewScrollListener
for endless scrolling in Litho?
I have had success implementing the "infinite" scroll pattern leveraging the
recyclerBinder
within theonScrolled
method of aOnScrollListener
. A trivial example would be the following:Then in a call back method - you can insert your items starting at the item count