DefaultItemTouchCallback

open class DefaultItemTouchCallback : ItemTouchHelper.Callback

默认实现拖拽替换和侧滑删除

Constructors

DefaultItemTouchCallback
Link copied to clipboard
fun DefaultItemTouchCallback()

Functions

clearView
Link copied to clipboard
open override fun clearView(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder)
getMovementFlags
Link copied to clipboard
open override fun getMovementFlags(recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder): Int
返回值表示拖拽/侧滑的方向
getSwipeThreshold
Link copied to clipboard
open override fun getSwipeThreshold(viewHolder: RecyclerView.ViewHolder): Float
滑动距离速率来判断当前是否执行滑动删除事件(可以理解为移出itemView)
onChildDraw
Link copied to clipboard
open override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean)
绘制拖拽或者侧滑动画
onDrag
Link copied to clipboard
open fun onDrag(source: BindingAdapter.BindingViewHolder, target: BindingAdapter.BindingViewHolder)
当拖拽动作完成且松开手指时触发
onMove
Link copied to clipboard
open override fun onMove(recyclerView: RecyclerView, source: RecyclerView.ViewHolder, target: RecyclerView.ViewHolder): Boolean
拖拽移动超过其他item时, 其返回值表示是否已经拖拽替换(会触发函数onMoved)
onSelectedChanged
Link copied to clipboard
open override fun onSelectedChanged(viewHolder: RecyclerView.ViewHolder?, actionState: Int)
拖拽或者侧滑导致的状态变化
onSwiped
Link copied to clipboard
open override fun onSwiped(viewHolder: RecyclerView.ViewHolder, direction: Int)
侧滑到底item消失时