I'm using a surfaceview where I just need to identify Up/Down finger swipes. I found this useful: How to handle right to left swipe gestures
However, I also want a given function to be called, say Foo(), whenever the user clicks on the surfaceview (just a single click). This is simple, but got really complicated when I added the gestures swipe thing.
Does anyone know how to do both: single touch events, and UP/Down finger swipes?
Here is what I tried:
Inside OnSwipeTouchListener:
public boolean onTouch(View v, MotionEvent event) { Foo(); return gestureDetector.onTouchEvent(event); }
But that resulted in calling Foo() from the moment the user starts the gesture, until the finger is released off the screen (hundreds of times).
I also tried discarding this OnSwipeTouchListener class and using onTouchEvent() inside the surface view itself. This worked for single touch events; however, I couldn't detect UP/Down swipes.
if (event.getAction() == MotionEvent.ACTION_DOWN) { mDownY = event.getY(); } else if (event.getAction() == MotionEvent.ACTION_UP) { // This code was never called!! }