Cancel long press when moving screen
This commit is contained in:
parent
c60f7f46ec
commit
01b5546fbb
1 changed files with 12 additions and 0 deletions
|
@ -110,6 +110,13 @@ class AreaAdapter(
|
||||||
var longClickJob: Job? = null
|
var longClickJob: Job? = null
|
||||||
view.setOnTouchListener { _, motionEvent ->
|
view.setOnTouchListener { _, motionEvent ->
|
||||||
when (motionEvent.action) {
|
when (motionEvent.action) {
|
||||||
|
MotionEvent.ACTION_MOVE -> {
|
||||||
|
longClickJob?.let { job ->
|
||||||
|
job.cancel()
|
||||||
|
longClickJob = null
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
view.isPressed = true
|
view.isPressed = true
|
||||||
longClickJob = coroutineScope.launch {
|
longClickJob = coroutineScope.launch {
|
||||||
|
@ -164,6 +171,11 @@ class AreaAdapter(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
longClickJob?.let { job ->
|
||||||
|
job.cancel()
|
||||||
|
longClickJob = null
|
||||||
|
}
|
||||||
}
|
}
|
||||||
handled
|
handled
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue