OnUp event on GestureDetector

Marcos Vasconcelos picture Marcos Vasconcelos · Apr 19, 2011 · Viewed 11.4k times · Source

My question is simple, where's the onUp event when implementing a GestureListener?

I has a lot of events on the gesturedetector, and cannot just consume the onUp event of the listener, cause one of events are the onSingleTapConfirmed that needs it.

Answer

adamwong246 picture adamwong246 · May 13, 2011

Try using onFling(). Seems like a weird name but for me, it works as the onUp() method would logically work. Or try this method...

@Override
public boolean onTouchEvent(MotionEvent me) {

  Log.v("ADAM", "ontouch: " + me.getAction());

  if(me.getAction() == 0){
    Log.v("ADAM", "Down");
  }
  else if (me.getAction() == 1) {
    Log.v("ADAM", "Up");
  }
  else if (me.getAction() == 2) {
    Log.v("ADAM", "Scroll");
  }
  boolean detectedUp = event.getAction() == MotionEvent.ACTION_UP;
  if (!mGestureDetector.onTouchEvent(event) && detectedUp) {
    return onUp(event);
  }
  return true;
}