Пример #1
0
  @Override
  protected void handleInProgressEvent(int actionCode, MotionEvent event) {
    switch (actionCode) {
      case MotionEvent.ACTION_UP:
      case MotionEvent.ACTION_CANCEL:
        mListener.onMoveEnd(this);
        resetState();
        break;

      case MotionEvent.ACTION_MOVE:
        updateStateByEvent(event);

        // Only accept the event if our relative pressure is within
        // a certain limit. This can help filter shaky data as a
        // finger is lifted.
        if (mCurrPressure / mPrevPressure > PRESSURE_THRESHOLD) {
          final boolean updatePrevious = mListener.onMove(this);
          if (updatePrevious) {
            mPrevEvent.recycle();
            mPrevEvent = MotionEvent.obtain(event);
          }
        }
        break;
    }
  }
Пример #2
0
 @Override
 protected void handleInProgressEvent(MotionEvent event) {
   int actionCode = event.getAction() & MotionEvent.ACTION_MASK;
   switch (actionCode) {
     case MotionEvent.ACTION_CANCEL:
     case MotionEvent.ACTION_UP:
       moveGestureListener.onMoveEnd(this);
       resetState();
       break;
     case MotionEvent.ACTION_MOVE:
       updateStateByEvent(event);
       boolean update = moveGestureListener.onMove(this);
       if (update) {
         mPreMotionEvent.recycle();
         mPreMotionEvent = MotionEvent.obtain(event);
       }
       break;
   }
 }
Пример #3
0
 @Override
 protected void handleStartProgressEvent(MotionEvent event) {
   int actionCode = event.getAction() & MotionEvent.ACTION_MASK;
   switch (actionCode) {
     case MotionEvent.ACTION_DOWN:
       resetState();
       mPreMotionEvent = MotionEvent.obtain(event);
       updateStateByEvent(event);
       break;
     case MotionEvent.ACTION_MOVE:
       mGestureInProgress = moveGestureListener.onMoveStart(this);
       break;
   }
 }
Пример #4
0
  @Override
  protected void handleStartProgressEvent(int actionCode, MotionEvent event) {
    switch (actionCode) {
      case MotionEvent.ACTION_DOWN:
        resetState(); // In case we missed an UP/CANCEL event

        mPrevEvent = MotionEvent.obtain(event);
        mTimeDelta = 0;

        updateStateByEvent(event);
        break;

      case MotionEvent.ACTION_MOVE:
        mGestureInProgress = mListener.onMoveBegin(this);
        break;
    }
  }