[fix] 拖动view 过程中window丢失
This commit is contained in:
@@ -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"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user