Skip to content

Commit

Permalink
fix: #397 禁止头脚布局被拖拽移动
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjingkanji committed Oct 29, 2023
1 parent 41d0be9 commit 0c7cf03
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ Module 的 build.gradle 添加依赖框架

```groovy
dependencies {
implementation 'com.github.liangjingkanji:BRV:1.5.3'
implementation 'com.github.liangjingkanji:BRV:1.5.4'
}
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,13 +141,17 @@ open class DefaultItemTouchCallback : ItemTouchHelper.Callback() {
onDrag(sourceViewHolder!!, targetViewHolder!!)
}
}

else -> {
this.lastActionState = actionState
}
}
}

/** 拖拽移动超过其他item时, 其返回值表示是否已经拖拽替换(会触发函数onMoved) */
/**
* 拖拽移动超过其他item时, 其返回值表示是否已经拖拽替换(会触发函数onMoved)
* @return 返回false 禁止被拖拽交换移动
*/
override fun onMove(
recyclerView: RecyclerView,
source: RecyclerView.ViewHolder,
Expand All @@ -158,7 +162,7 @@ open class DefaultItemTouchCallback : ItemTouchHelper.Callback() {
val targetPosition = recyclerView.getChildLayoutPosition(target.itemView)

val models = adapter.models as? MutableList
if (models != null && source is BindingViewHolder && target is BindingViewHolder) {
if (models != null && source is BindingViewHolder && target is BindingViewHolder && adapter.isModel(targetPosition)) {
val fromPosition = currentPosition - adapter.headerCount
val toPosition = targetPosition - adapter.headerCount
val fromItem = models[fromPosition]
Expand Down
3 changes: 3 additions & 0 deletions docs/updates.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## 1.5.4
- fix: #397 禁止头脚布局被拖拽移动

## 1.5.3
- fix: 禁止`PageRefreshLayout.setNoMoreData`重复调用

Expand Down

0 comments on commit 0c7cf03

Please sign in to comment.