SwipeList Sample: After swipe, disable swipe ability
The sample does not prevent rows from swiping multiple times, whilst the row is already swiped. It's better to disable swiping when a row has been swiped.
I haven't found an easy solution yet, i.e. setting item.WithEnabled(false) has no noticable change.
When I try to swipe a lot of times on a single row, then sometimes a bug pops up: The colored view stays visible, even when the row has been removed. And it even stays at the same spot when I scroll.

hi mikepenz, thank you for yours fast adapter, i have some isue when using swipe list sample, i want to call approve function if i swipe to right and call reject function if i swipe to left,iam not clear where to call it. i have try in function itemSwiped but i dont know how to identify left or right. can you help me, thank you iam new on android and java
Hi anton-khansa,
In the sample app, in SwipeListActivity.java you will find an override of itemSwiped(). There is a variable called "direction". You can use that.
@Override
public void itemSwiped(int position, int direction) {
}
hi echthard, thank you for your response, i want to call this function :
- call function approve() if swipe right
- call function reject() if swipe left
where should i call that?iam still dont know how to identify left or right, could u help me?really appreciated for your help.below is the function from SwipeListActivity.java.
@Override
public void itemSwiped(int position, int direction) {
final SwipeableItem item = fastItemAdapter.getItem(position);
item.setSwipedDirection(direction);
final Runnable removeRunnable = new Runnable() {
@Override
public void run() {
item.setSwipedAction(null);
int position = fastItemAdapter.getAdapterPosition(item);
if (position != RecyclerView.NO_POSITION) {
fastItemAdapter.remove(position);
}
}
};
final View rv = findViewById(R.id.rv);
rv.postDelayed(removeRunnable, 3000);
item.setSwipedAction(new Runnable() {
@Override
public void run() {
rv.removeCallbacks(removeRunnable);
item.setSwipedDirection(0);
int position = fastItemAdapter.getAdapterPosition(item);
if (position != RecyclerView.NO_POSITION) {
fastItemAdapter.notifyItemChanged(position);
}
}
});
fastItemAdapter.notifyItemChanged(position);
}
@Override
public void itemSwiped(int position, int direction) {
if (direction == ItemTouchHelper.RIGHT) {
approve();
} else if (direction == ItemTouchHelper.LEFT) {
reject();
}
... // rest what you want to do with it.
}
with v2.1.7 there is now a new ISwipeable interface which allows you to disable swiping on a per-item basis