I want to use the new ItemTouchHelper from the v7 design library. I use it inside of a SwipeRefreshLayout.
The problem is that with the SwipeRefreshLayout the animation for the swipe to dismiss is wrong and buggy.
Anyone knows how to fix this?
You could disable your SwipeRefreshLayout as long as you are swiping.
final ItemTouchHelper itemTouchHelper = new ItemTouchHelper(new ItemTouchHelper.Callback() {
@Override
public int getMovementFlags(RecyclerView recyclerView, ViewHolder viewHolder) {
return makeMovementFlags(0, ItemTouchHelper.START | ItemTouchHelper.END);
}
@Override
public boolean onMove(RecyclerView recyclerView, ViewHolder viewHolder, ViewHolder target) {
return false;
}
@Override
public void onSwiped(ViewHolder viewHolder, int direction) {
// do something
}
@Override
public void onSelectedChanged(ViewHolder viewHolder, int actionState) {
super.onSelectedChanged(viewHolder, actionState);
final boolean swiping = actionState == ItemTouchHelper.ACTION_STATE_SWIPE;
swipeRefreshLayout.setEnabled(!swiping);
}
});
itemTouchHelper.attachToRecyclerView(recyclerView);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With