3

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;
        }
    });
}
Mantaz
  • 333
  • 1
  • 4
  • 12
  • Were you able to solve this? I'm facing this exact issue right now. Doing 'recyclerview.removeAllviews();' and then 'controller.requestmodelbuild' is working but I'm looking for a proper fix. – happyvirus Jun 20 '20 at 18:11
  • @happyvirus did you find a solution? it's my turn to be having this problem – shil88 Jul 19 '22 at 15:54

1 Answers1

0

add controller.notifyModelChanged(position); to onSwipeCompleted() to notify the controller to revert the swipe.

shil88
  • 1,449
  • 1
  • 11
  • 13