Open Fuusio opened 7 years ago
Hi. Thank you for using my library!
Is there any method or way to reset the default position of a swiped item and with animation?
There is no special method exists for the purpose, but RecyclerView.Adapter.notifyItemChanged()
and SwipeableItemViewHolder.setSwipeItemHorizontalSlideAmount()
can be used.
Clear "pinned" flag & notify item changes
mAdapter.getItem( clickedItemIndex ).setPinned(false);
mAdapter.notifyItemChanged( clickedItemIndex );
Reset to default position in onBindViewHolder
public void onBindViewHolder(MyViewHolder holder, int position) {
final AbstractDataProvider.Data item = getItem(position);
holder.setSwipeItemHorizontalSlideAmount(
item.isPinned() ? Swipeable.OUTSIDE_OF_THE_WINDOW_LEFT : 0);
...
}
Please refer to the "Swipeable (Basic)" demo implementation for more details. In the demo, same technique is used when clicking the yellow area of pinned item.
Thanks!
First of all, thank you for the awesome library! I am a one happy user :)
Is there any method or way to reset the default position of a swiped item and with animation?
My use case is as follows. A user swipes a list item to reveal a set of actions buttons, and when the user clicks on any of the action, the item should be moved programmatically back to default position where it was before swiping.
For implementing that kind of behaviour, I already added method
RecyclerViewSwipeManager#resetSwipedItemPosition(RecyclerView.ViewHolder swipedItem, int itemPosition)
to my own fork, but I would prefer not to use fork if there is an already existing method to restore the default position.Thank you in advance.