From 90d25ff45e44c833889690d58e2604f25cb730f1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 17 Jul 2019 14:41:01 +0200 Subject: [PATCH] Code cleanup --- .../detail/RoomMessageTouchHelperCallback.kt | 22 +++++++++++++------ 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomMessageTouchHelperCallback.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomMessageTouchHelperCallback.kt index 2803c66b..cb283511 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomMessageTouchHelperCallback.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/RoomMessageTouchHelperCallback.kt @@ -78,15 +78,21 @@ class RoomMessageTouchHelperCallback(private val context: Context, //We never let items completely go out override fun convertToAbsoluteDirection(flags: Int, layoutDirection: Int): Int { if (swipeBack) { - swipeBack = false; - return 0; + swipeBack = false + 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) { - setTouchListener(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); + setTouchListener(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive) } val size = triggerDistance 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, recyclerView: RecyclerView, viewHolder: EpoxyViewHolder, - dX: Float, dY: Float, - actionState: Int, isCurrentlyActive: Boolean) { + dX: Float, + dY: Float, + actionState: Int, + isCurrentlyActive: Boolean) { //TODO can this interfer with other interactions? should i remove it recyclerView.setOnTouchListener { v, event -> swipeBack = event.action == MotionEvent.ACTION_CANCEL || event.action == MotionEvent.ACTION_UP