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

Sorts are not equal #55

Closed Bender42 closed 6 years ago

Bender42 commented 6 years ago

https://github.com/iPaulPro/Android-ItemTouchHelper-Demo/blob/d164fba0f27c8aa38cfa7dbd4bc74d53dea44605/app/src/main/java/co/paulburke/android/itemtouchhelperdemo/RecyclerListAdapter.java#L90

Сhanges in lists Collections.swap(mItems, fromPosition, toPosition) and notifyItemMoved(fromPosition, toPosition) not the same.

You can check it by calling recyclerView.getAdapter().notifyDataSetChanged(); in SimpleItemTouchHelperCallback#clearView()

My simple solution is:

String item = mItems.get(fromPosition);
expenditures.remove(fromPosition);
expenditures.add(toPosition, item);