Skip to content

Commit

Permalink
fix: #461 修复拖拽交换禁止拖拽的item未触发onDrag函数
Browse files Browse the repository at this point in the history
  • Loading branch information
SupCheny authored and liangjingkanji committed Nov 30, 2024
1 parent e43262f commit 1bcb255
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,10 @@ open class DefaultItemTouchCallback : ItemTouchHelper.Callback() {
val source = sourceViewHolder
val target = targetViewHolder
if (lastActionState == ItemTouchHelper.ACTION_STATE_DRAG &&
source is BindingViewHolder && target is BindingViewHolder &&
startMovingPosition != target.bindingAdapterPosition
source is BindingViewHolder &&
target is BindingViewHolder &&
startMovingPosition != null &&
startMovingPosition != source.bindingAdapterPosition
) {
onDrag(source, target)
}
Expand Down Expand Up @@ -178,12 +180,12 @@ open class DefaultItemTouchCallback : ItemTouchHelper.Callback() {
adapter.notifyItemMoved(currentPosition, targetPosition)
// 记录起始移动位置
if (startMovingPosition == null) {
startMovingPosition = source.bindingAdapterPosition
startMovingPosition = target.bindingAdapterPosition
}
sourceViewHolder = source
targetViewHolder = target
return true
}
return false
}
}
}

0 comments on commit 1bcb255

Please sign in to comment.