From 757b143c1665b53cde26f300977314a98e68f2b4 Mon Sep 17 00:00:00 2001 From: yangyakun Date: Fri, 30 Dec 2022 16:05:02 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E6=8B=96=E5=8A=A8view=20=E8=BF=87?= =?UTF-8?q?=E7=A8=8B=E4=B8=ADwindow=E4=B8=A2=E5=A4=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/leftmenu/ItemViewTouchListener.kt | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/leftmenu/ItemViewTouchListener.kt b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/leftmenu/ItemViewTouchListener.kt index 1aa1e9afa3..f9cd1a55b8 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/leftmenu/ItemViewTouchListener.kt +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/leftmenu/ItemViewTouchListener.kt @@ -3,6 +3,8 @@ package com.mogo.och.taxi.passenger.ui.leftmenu import android.annotation.SuppressLint import android.view.MotionEvent import android.view.View +import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger +import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant class ItemViewTouchListener : View.OnTouchListener { @@ -10,25 +12,34 @@ class ItemViewTouchListener : private var dragTime = 0L @SuppressLint("ClickableViewAccessibility") override fun onTouch(view: View, motionEvent: MotionEvent): Boolean { - when (motionEvent.action) { - MotionEvent.ACTION_DOWN -> { - LeftMenuOpen.dragAndOpen(motionEvent.rawX.toInt(),motionEvent.action) - dragTime = System.currentTimeMillis() - } - MotionEvent.ACTION_MOVE -> { - if (LeftMenuOpen.dragAndOpen(motionEvent.rawX.toInt(),motionEvent.action)) { - return false + try { + when (motionEvent.action) { + MotionEvent.ACTION_DOWN -> { + LeftMenuOpen.dragAndOpen(motionEvent.rawX.toInt(),motionEvent.action) + dragTime = System.currentTimeMillis() } - } - MotionEvent.ACTION_UP -> { - LeftMenuOpen.dragAndOpen(motionEvent.rawX.toInt(),motionEvent.action) - if (System.currentTimeMillis() - dragTime > 500) { - dragTime = 0 - return true + MotionEvent.ACTION_MOVE -> { + if (LeftMenuOpen.dragAndOpen(motionEvent.rawX.toInt(),motionEvent.action)) { + return false + } } + MotionEvent.ACTION_UP -> { + LeftMenuOpen.dragAndOpen(motionEvent.rawX.toInt(),motionEvent.action) + if (System.currentTimeMillis() - dragTime > 500) { + dragTime = 0 + return true + } + } + else -> {} } - else -> {} + } catch (e: Exception) { + CallerLogger.e(SceneConstant.M_TAXI_P + TAG, e.message) + e.printStackTrace() } return false } + + companion object { + const val TAG = "ItemViewTouchListener" + } } \ No newline at end of file