예제 #1
0
  /** Handles reset button click. */
  private void onZoomResetButtonClick() {
    // resets image view scale and translation and makes it fit in screen's center
    mPinchToZoomTransformation.reset();
    updateImageView();

    updateZoomTextViewText();

    scaleTv(0, mImageViewWidth / 2.0f, mImageViewHeight / 2.0f);
  }
예제 #2
0
  /** Updates application UI and image on TV according to rotation values. */
  private void updateUiAndTvRotation(RotationDirection rotationDirection) {
    PinchToZoomTransformation.RotationDirection pinchToZoomRotationDirection =
        rotationDirection == RotationDirection.CLOCKWISE
            ? PinchToZoomTransformation.RotationDirection.CLOCKWISE
            : PinchToZoomTransformation.RotationDirection.COUNTER_CLOCKWISE;

    mPinchToZoomTransformation.updateRotationAndFitInBounds(pinchToZoomRotationDirection);

    updateImageView();

    scaleTv(0, mImageViewWidth / 2.0f, mImageViewHeight / 2.0f);

    updateZoomTextViewText();
  }
예제 #3
0
  /** Updates application UI and image on TV according to scale values. */
  private void updateUiAndTvScale(float scaleFactorDelta, float scalePointX, float scalePointY) {
    // rounds scale values so that they are the same as those accepted by ViewController
    float roundedScaleFactorDelta = (float) ((int) (scaleFactorDelta * 100)) / 100;
    float roundedScalePointX = (int) scalePointX;
    float roundedScalePointY = (int) scalePointY;

    // applies rounded scale to transformation object
    // additionally the scale that was applied after bounds check is stored in newScaleFactorDelta
    float newScaleFactorDelta =
        mPinchToZoomTransformation.updateScaleInBounds(
            roundedScaleFactorDelta, roundedScalePointX, roundedScalePointY);

    updateImageView();

    scaleTv(newScaleFactorDelta, roundedScalePointX, roundedScalePointY);

    updateZoomTextViewText();
  }