is there any sample that implemented load more when reaching at the end of recyclerView?
No there isn't currently a sample for loading more, but it works the same as any other RecyclerView pagination set up. Epoxy is mostly unrelated to how you implement loading more.
If you're looking for a generic approach for RecyclerView to load more check out https://gist.github.com/nesquena/d09dc68ff07e845cc622
A pattern I often use is simpler. I have a loading model that I add last in the adapter. In onModelBound I check if loadingModel == boundModel and if so I know it's at the end of the list and I should load more.
There are quite a few ways to implement loading more and you're free to choose the best for your situation. Epoxy tries not to interfere with how you choose to implement it, which is why we don't provide any built in support for it.
let me know if anyone would like to share your repos for the pagination support on epoxy thanks!
@jjhesk you can do something like this with a scroll listener https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView
which works completely independently of Epoxy.
however, what we usually do is something simple like this
@AutoModel MyLoaderModel_ myLoaderModel;
private final Listener listener
public MyController(Listener listener) {
this.listener = listener;
}
@Override
protected void buildModels() {
...
myLoaderModel
.onBind((model, view, position) -> {
if (listener.hasMoreToLoad()) {
listener.fetchNextPage();
}
})
.addIf(listener.hasMoreToLoad(), this);
}
we have a model which is just a simple view with an animation showing a loader. we add that last if we have things to load and make a callback to load more when the spinner is about to come on screen.
the first approach will work better if you want to preload before the spinner comes on screen though.
I'll try to add a section on this to the wiki some time
Most helpful comment
@jjhesk you can do something like this with a scroll listener https://github.com/codepath/android_guides/wiki/Endless-Scrolling-with-AdapterViews-and-RecyclerView
which works completely independently of Epoxy.
however, what we usually do is something simple like this
we have a model which is just a simple view with an animation showing a loader. we add that last if we have things to load and make a callback to load more when the spinner is about to come on screen.
the first approach will work better if you want to preload before the spinner comes on screen though.
I'll try to add a section on this to the wiki some time