-
Notifications
You must be signed in to change notification settings - Fork 726
Infinite Scroll
Eli Hart edited this page Aug 19, 2017
·
1 revision
work in progress
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.