コード例 #1
0
  @Override
  public boolean dispatchTouchEvent(MotionEvent event) {
    if (!onFilterTouchEventForSecurity(event)) return false;

    int action = event.getAction();

    double dx = event.getX() - mCenterX;
    double dy = mCenterY - event.getY();
    double radius = Math.sqrt(dx * dx + dy * dy);

    // Check if the event should be dispatched to the shutter button.
    if (radius <= mShutterButtonRadius) {
      if (mIndicatorControlWheel.getVisibility() == View.VISIBLE) {
        mIndicatorControlWheel.onTouchOutBound();
      } else {
        return mZoomControlWheel.dispatchTouchEvent(event);
      }
      if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) {
        return mShutterButton.dispatchTouchEvent(event);
      }
      return false;
    }

    if (mShutterButton.isPressed()) {
      // Send cancel to the shutter button if it was pressed.
      event.setAction(MotionEvent.ACTION_CANCEL);
      mShutterButton.dispatchTouchEvent(event);
      return true;
    }

    if (mIndicatorControlWheel.getVisibility() == View.VISIBLE) {
      return mIndicatorControlWheel.dispatchTouchEvent(event);
    } else {
      return mZoomControlWheel.dispatchTouchEvent(event);
    }
  }