Skip to content

Commit

Permalink
Fix a bug when user delete item right after drag it
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhan6665 committed Aug 13, 2021
1 parent ae2b10e commit 7052546
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ class MainRecyclerAdapter(val activity: MainActivity) : RecyclerView.Adapter<Mai
override fun onItemMove(fromPosition: Int, toPosition: Int): Boolean {
mActivity.mainViewModel.swapServer(fromPosition, toPosition)
notifyItemMoved(fromPosition, toPosition)
//notifyItemRangeChanged(fromPosition, toPosition - fromPosition + 1)
// position is changed, since position is used by click callbacks, need to update range
if (toPosition > fromPosition)
notifyItemRangeChanged(fromPosition, toPosition - fromPosition + 1)
else
notifyItemRangeChanged(toPosition, fromPosition - toPosition + 1)
return true
}

Expand Down

0 comments on commit 7052546

Please sign in to comment.