iPaulPro / Android-ItemTouchHelper-Demo

Basic example of using ItemTouchHelper to add drag & drop and swipe-to-dismiss to RecyclerView.
Apache License 2.0
2.51k stars 499 forks source link

Position of item not getting changed when its moved #51

Closed TonyHaddad91 closed 7 years ago

TonyHaddad91 commented 7 years ago

Thanks for this great demo

I have an issue while i'm using it with GridLayout manager that the item keeps there old positions e.g. if i moved an item from position 0 to position 3 when i click on it and print out the position it will give me 0 also

even tho i added this snippet which is can be related to this issue

public boolean onItemMove(int fromPosition, int toPosition) { if (fromPosition < toPosition) { for (int i = fromPosition; i < toPosition; i++) { Collections.swap(mItems, i, i + 1); } } else { for (int i = fromPosition; i > toPosition; i--) { Collections.swap(mItems, i, i - 1); } } notifyItemMoved(fromPosition, toPosition); return true; }

Thanks