Exemplo n.º 1
0
  public boolean onRotate(RotateGestureDetector detector) {

    float rotation = detector.getRotationRadiansDelta();

    /*
     * If Shove is in progress do not handle rotation
     * If previous rotation is handled then keep on handling it
     * else give some buffer for shove to be processed
     */
    if (mRotationHandled || (!mShoveHandled && (Math.abs(rotation) > ROTATION_THRESHOLD))) {
      float rotAngle;

      // Compensate for the ROTATION_THRESHOLD at the very beginning of the gesture, to avoid
      // rotation jumps
      if (!mRotationHandled) {
        rotAngle =
            (rotation > 0) ? (rotation - ROTATION_THRESHOLD) : (rotation + ROTATION_THRESHOLD);
      } else {
        rotAngle = rotation;
      }
      float x = rotateGestureDetector.getFocusX();
      float y = rotateGestureDetector.getFocusY();
      mLastDoubleGestureTime = detector.getEventTime();
      handleRotateGesture(x, y, -(rotAngle));
      mRotationHandled = true;
      return true;
    }
    mRotationHandled = false;
    return false;
  }
Exemplo n.º 2
0
  public boolean onTouch(View v, MotionEvent event) {

    if (genericMotionListener != null) {
      genericMotionListener.onGenericMotion(v, event);
    }

    gestureDetector.onTouchEvent(event);
    scaleGestureDetector.onTouchEvent(event);
    shoveGestureDetector.onTouchEvent(event);
    rotateGestureDetector.onTouchEvent(event);

    return true;
  }