K
K
Kruger2018-08-10 11:26:00
Android
Kruger, 2018-08-10 11:26:00

How to interrupt onTouchEvent(Kotlin) code?

There is a conditional code.

spoiler
@SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_DOWN -> {
Log.d(TAG,"TAP ")
}
MotionEvent.ACTION_MOVE -> {
}
MotionEvent.ACTION_UP -> {
тут какой то код
цикл
}
MotionEvent.ACTION_CANCEL -> {
}
}
return true
}

The user takes his finger away from the screen, inside the event some code is executed, for example a loop. How to exit it if the user touches the screen again? What to check?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
alterEgoChaos, 2018-08-10
@KrUgerD

Separately take out the logic - while(notTouch) {
} or do {}while depending on the logic
in the onTouch method notTouch = true/false, set and rejoice

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question