Skip to content

Commit

Permalink
Merge pull request 2dust#1183 from yuhan6665/fix-drag
Browse files Browse the repository at this point in the history
Fix a bug when user delete item right after drag it
  • Loading branch information
2dust authored Aug 17, 2021
2 parents ae2b10e + 7052546 commit 26cc299
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 26cc299

Please sign in to comment.