Code cleanup
This commit is contained in:
parent
173452d38c
commit
90d25ff45e
|
@ -78,15 +78,21 @@ class RoomMessageTouchHelperCallback(private val context: Context,
|
||||||
//We never let items completely go out
|
//We never let items completely go out
|
||||||
override fun convertToAbsoluteDirection(flags: Int, layoutDirection: Int): Int {
|
override fun convertToAbsoluteDirection(flags: Int, layoutDirection: Int): Int {
|
||||||
if (swipeBack) {
|
if (swipeBack) {
|
||||||
swipeBack = false;
|
swipeBack = false
|
||||||
return 0;
|
return 0
|
||||||
}
|
}
|
||||||
return super.convertToAbsoluteDirection(flags, layoutDirection);
|
return super.convertToAbsoluteDirection(flags, layoutDirection)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onChildDraw(c: Canvas, recyclerView: RecyclerView, viewHolder: EpoxyViewHolder, dX: Float, dY: Float, actionState: Int, isCurrentlyActive: Boolean) {
|
override fun onChildDraw(c: Canvas,
|
||||||
|
recyclerView: RecyclerView,
|
||||||
|
viewHolder: EpoxyViewHolder,
|
||||||
|
dX: Float,
|
||||||
|
dY: Float,
|
||||||
|
actionState: Int,
|
||||||
|
isCurrentlyActive: Boolean) {
|
||||||
if (actionState == ACTION_STATE_SWIPE) {
|
if (actionState == ACTION_STATE_SWIPE) {
|
||||||
setTouchListener(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
setTouchListener(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive)
|
||||||
}
|
}
|
||||||
val size = triggerDistance
|
val size = triggerDistance
|
||||||
if (Math.abs(viewHolder.itemView.translationX) < size || dX > this.dX /*going back*/) {
|
if (Math.abs(viewHolder.itemView.translationX) < size || dX > this.dX /*going back*/) {
|
||||||
|
@ -102,8 +108,10 @@ class RoomMessageTouchHelperCallback(private val context: Context,
|
||||||
private fun setTouchListener(c: Canvas,
|
private fun setTouchListener(c: Canvas,
|
||||||
recyclerView: RecyclerView,
|
recyclerView: RecyclerView,
|
||||||
viewHolder: EpoxyViewHolder,
|
viewHolder: EpoxyViewHolder,
|
||||||
dX: Float, dY: Float,
|
dX: Float,
|
||||||
actionState: Int, isCurrentlyActive: Boolean) {
|
dY: Float,
|
||||||
|
actionState: Int,
|
||||||
|
isCurrentlyActive: Boolean) {
|
||||||
//TODO can this interfer with other interactions? should i remove it
|
//TODO can this interfer with other interactions? should i remove it
|
||||||
recyclerView.setOnTouchListener { v, event ->
|
recyclerView.setOnTouchListener { v, event ->
|
||||||
swipeBack = event.action == MotionEvent.ACTION_CANCEL || event.action == MotionEvent.ACTION_UP
|
swipeBack = event.action == MotionEvent.ACTION_CANCEL || event.action == MotionEvent.ACTION_UP
|
||||||
|
|
Loading…
Reference in New Issue