Как сделать что-бы при перетаскивании элемента списка не отрисовывалать корзина и фон?
Есть список recyclerView. Элементы которого можно удалять свайпом влево. Также их можно перетаскивать и менять местами. В функции onChildDraw есть код, который внутри элемента списка рисует значек корзины и фон удаления. Как сделать что-бы во время перетаскивания элемента списка корзина и фон не отрисовывались? Фрагмент кода с функцией onChildDraw:
override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: RecyclerView.ViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
val itemView = viewHolder.itemView
val itemHeight = itemView.height
val isCancelled = dX == 0f && !isCurrentlyActive
if (isCancelled) {
//clearCanvas(c, itemView.right + dX, itemView.top.toFloat(), itemView.right.toFloat(), itemView.bottom.toFloat())
c.drawRect(itemView.right + dX, itemView.top.toFloat(), itemView.right.toFloat(), itemView.bottom.toFloat(), Paint())
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
return
}
val deleteDrawable = ContextCompat.getDrawable(requireContext(), R.drawable.ic_delete_black_24dp);
val intrinsicWidth = deleteDrawable!!.getIntrinsicWidth();
val intrinsicHeight = deleteDrawable.getIntrinsicHeight();
val mBackground = ColorDrawable()
mBackground.color = Color.parseColor("#D81B60")//"#b80f0a")
mBackground.setBounds(itemView.right + (dX*1/columnsCount).toInt(), itemView.top, itemView.right, itemView.bottom)
mBackground.draw(c)
val deleteIconTop = itemView.top + (itemHeight - intrinsicHeight) / 2
val deleteIconMargin = (itemHeight - intrinsicHeight) / (columnsCount * columnsCount)
val deleteIconLeft = itemView.right - deleteIconMargin - intrinsicWidth
val deleteIconRight = itemView.right - deleteIconMargin
val deleteIconBottom = deleteIconTop + intrinsicHeight
deleteDrawable.setBounds(deleteIconLeft, deleteIconTop, deleteIconRight, deleteIconBottom)
deleteDrawable.draw(c)
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
}