Fixed swipe gesture
This commit is contained in:
parent
33e932e630
commit
b825b33250
@ -222,52 +222,28 @@ class SwipeableMessageAdapter : RecyclerView.Adapter<SwipeableMessageAdapter.Vie
|
|||||||
notifyItemChanged(selectedPosition)
|
notifyItemChanged(selectedPosition)
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SwipeLeftResultAction internal constructor(adapter: SwipeableMessageAdapter, private val position: Int) : SwipeResultActionMoveToSwipedDirection() {
|
private class SwipeLeftResultAction internal constructor(adapter: SwipeableMessageAdapter, position: Int) : SwipeResultActionMoveToSwipedDirection() {
|
||||||
private var adapter: SwipeableMessageAdapter? = adapter
|
private var adapter: SwipeableMessageAdapter? = adapter
|
||||||
private val item = adapter.data[position]
|
private val item = adapter.data[position]
|
||||||
|
|
||||||
override fun onPerformAction() {
|
override fun onPerformAction() {
|
||||||
super.onPerformAction()
|
|
||||||
|
|
||||||
adapter?.apply {
|
|
||||||
data.removeAt(position)
|
|
||||||
notifyItemRemoved(position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSlideAnimationEnd() {
|
|
||||||
super.onSlideAnimationEnd()
|
|
||||||
adapter?.eventListener?.onItemDeleted(item)
|
adapter?.eventListener?.onItemDeleted(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleanUp() {
|
override fun onCleanUp() {
|
||||||
super.onCleanUp()
|
|
||||||
// clear the references
|
|
||||||
adapter = null
|
adapter = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class SwipeRightResultAction internal constructor(adapter: SwipeableMessageAdapter, private val position: Int) : SwipeResultActionRemoveItem() {
|
private class SwipeRightResultAction internal constructor(adapter: SwipeableMessageAdapter, position: Int) : SwipeResultActionRemoveItem() {
|
||||||
private var adapter: SwipeableMessageAdapter? = adapter
|
private var adapter: SwipeableMessageAdapter? = adapter
|
||||||
private val item = adapter.data[position]
|
private val item = adapter.data[position]
|
||||||
|
|
||||||
override fun onPerformAction() {
|
override fun onPerformAction() {
|
||||||
super.onPerformAction()
|
|
||||||
|
|
||||||
adapter?.apply {
|
|
||||||
data.removeAt(position)
|
|
||||||
notifyItemRemoved(position)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun onSlideAnimationEnd() {
|
|
||||||
super.onSlideAnimationEnd()
|
|
||||||
adapter?.eventListener?.onItemArchived(item)
|
adapter?.eventListener?.onItemArchived(item)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleanUp() {
|
override fun onCleanUp() {
|
||||||
super.onCleanUp()
|
|
||||||
// clear the references
|
|
||||||
adapter = null
|
adapter = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user