-
Notifications
You must be signed in to change notification settings - Fork 732
Touch Support
Eli Hart edited this page Aug 10, 2017
·
12 revisions
(Since 2.3.0)
Epoxy helps you easily integrate RecyclerView's ItemTouchHelper with your Epoxy controllers and models. There is support for both dragging and swiping views.
The sample app demonstrates a bit of what is possible:
The easiest way to do this is through the EpoxyTouchHelper class.
Initialize dragging with an EpoxyController like this:
EpoxyTouchHelper.initDragging(epoxyController)
.withRecyclerView(recyclerView)
.forVerticalList()
.withTarget(MyModel.class)
.andCallbacks(new DragCallback<CarouselModelGroup>() {
@Override
public void onModelMoved(int fromPosition, int toPosition,
MyModel modelBeingMoved, View itemView) {
}
});
Initialize swiping like this:
EpoxyTouchHelper.initSwiping(recyclerView)
.leftAndRight()
.withTarget(MyModel.class)
.andCallbacks(new SwipeCallbacks<CarouselModelGroup>() {
@Override
public void onSwipeCompleted(MyModel model, View itemView, int position,
int direction) {
carousels.remove(model.data);
updateController();
}
});