Search code examples
androidevent-listenergesturedetector

OnUp event on GestureDetector


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.


Solution

  • 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;
    }