I am using EpoxyTouchHelper. onSwipeCompleted view disappears leaving empty space. I update controller's data with updated data controller.setData(List<item>);
but it doesn't help.
As well swipe stops working and I can't swipe any other item.
privat Items items;
private void updateData() {
controller.setData(items);
}
private void initTouch(final RecyclerView recyclerView) {
EpoxyTouchHelper.initSwiping(recyclerView)
.leftAndRight()
.withTarget(ItemListViewModel_.class)
.andCallbacks(new EpoxyTouchHelper.SwipeCallbacks<ItemListViewModel_>() {
@Override
public void onSwipeCompleted(ItemListViewModel_ model, View itemView, int position, int direction) {
int id = model.exeId();
items.removeItemFromListAndDbById(id);
updateData();
}
@Override
public void clearView(ItemListViewModel_ model, View itemView) {
itemView.setBackgroundColor(Color.WHITE);
}
@Override
public boolean isSwipeEnabledForModel(ItemListViewModel_ model) {
if ( model.itIsNewButton()) return false;
return true;
}
});
}
add
controller.notifyModelChanged(position);
to onSwipeCompleted() to notify the controller to revert the swipe.