Java Code Examples for android.view.ScaleGestureDetector#getCurrentSpanX()

The following examples show how to use android.view.ScaleGestureDetector#getCurrentSpanX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CropOverlayView.java    From timecat with Apache License 2.0 6 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
    RectF rect = mCropWindowHandler.getRect();

    float x = detector.getFocusX();
    float y = detector.getFocusY();
    float dY = detector.getCurrentSpanY() / 2;
    float dX = detector.getCurrentSpanX() / 2;

    float newTop = y - dY;
    float newLeft = x - dX;
    float newRight = x + dX;
    float newBottom = y + dY;

    if (newLeft < newRight && newTop <= newBottom && newLeft >= 0 && newRight <= mCropWindowHandler.getMaxCropWidth() && newTop >= 0 && newBottom <= mCropWindowHandler.getMaxCropHeight()) {

        rect.set(newLeft, newTop, newRight, newBottom);
        mCropWindowHandler.setRect(rect);
        invalidate();
    }

    return true;
}
 
Example 2
Source File: RxSeatMovie.java    From RxTools-master with Apache License 2.0 6 votes vote down vote up
@Override
public boolean onScale(ScaleGestureDetector detector) {
    isScaling = true;
    float scaleFactor = detector.getScaleFactor();
    if (getMatrixScaleY() * scaleFactor > 3) {
        scaleFactor = 3 / getMatrixScaleY();
    }
    if (firstScale) {
        scaleX = detector.getCurrentSpanX();
        scaleY = detector.getCurrentSpanY();
        firstScale = false;
    }

    if (getMatrixScaleY() * scaleFactor < 0.5) {
        scaleFactor = 0.5f / getMatrixScaleY();
    }
    matrix.postScale(scaleFactor, scaleFactor, scaleX, scaleY);
    invalidate();
    return true;
}
 
Example 3
Source File: CropOverlayView.java    From Lassi-Android with MIT License 5 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
    RectF rect = mCropWindowHandler.getRect();

    float x = detector.getFocusX();
    float y = detector.getFocusY();
    float dY = detector.getCurrentSpanY() / 2;
    float dX = detector.getCurrentSpanX() / 2;

    float newTop = y - dY;
    float newLeft = x - dX;
    float newRight = x + dX;
    float newBottom = y + dY;

    if (newLeft < newRight
            && newTop <= newBottom
            && newLeft >= 0
            && newRight <= mCropWindowHandler.getMaxCropWidth()
            && newTop >= 0
            && newBottom <= mCropWindowHandler.getMaxCropHeight()) {

        rect.set(newLeft, newTop, newRight, newBottom);
        mCropWindowHandler.setRect(rect);
        invalidate();
    }

    return true;
}
 
Example 4
Source File: CropOverlayView.java    From giffun with Apache License 2.0 5 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
  RectF rect = mCropWindowHandler.getRect();

  float x = detector.getFocusX();
  float y = detector.getFocusY();
  float dY = detector.getCurrentSpanY() / 2;
  float dX = detector.getCurrentSpanX() / 2;

  float newTop = y - dY;
  float newLeft = x - dX;
  float newRight = x + dX;
  float newBottom = y + dY;

  if (newLeft < newRight
      && newTop <= newBottom
      && newLeft >= 0
      && newRight <= mCropWindowHandler.getMaxCropWidth()
      && newTop >= 0
      && newBottom <= mCropWindowHandler.getMaxCropHeight()) {

    rect.set(newLeft, newTop, newRight, newBottom);
    mCropWindowHandler.setRect(rect);
    invalidate();
  }

  return true;
}
 
Example 5
Source File: ScaleGestureCompat.java    From Cinema-App-Concept with MIT License 5 votes vote down vote up
/**
 * @see ScaleGestureDetector#getCurrentSpanX()
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static float getCurrentSpanX(ScaleGestureDetector scaleGestureDetector) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        return scaleGestureDetector.getCurrentSpanX();
    } else {
        return scaleGestureDetector.getCurrentSpan();
    }
}
 
Example 6
Source File: Chart.java    From JZAndroidChart with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onScaleBegin(ScaleGestureDetector scaleGestureDetector) {
    if (!mScaleGestureEnable) return super.onScaleBegin(scaleGestureDetector);

    lastSpanX = scaleGestureDetector.getCurrentSpanX();
    return true;
}
 
Example 7
Source File: Chart.java    From JZAndroidChart with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onScale(ScaleGestureDetector scaleGestureDetector) {

    if (!mScaleXEnable) return false;
    if (!mScaleGestureEnable) return super.onScale(scaleGestureDetector);

    float spanX = scaleGestureDetector.getCurrentSpanX();

    float newWidth = lastSpanX / spanX * mCurrentViewport.width();

    if (newWidth < mCurrentViewport.width() && mCurrentViewport.width() < 0.001) {
        return true;
    }

    float focusX = scaleGestureDetector.getFocusX();
    float focusY = scaleGestureDetector.getFocusY();
    hitTest(focusX, focusY, viewportFocus);

    mCurrentViewport.left = viewportFocus.x
            - newWidth * (focusX - mContentRect.left)
            / mContentRect.width();

    mCurrentViewport.right = mCurrentViewport.left + newWidth;
    mCurrentViewport.constrainViewport();
    triggerViewportChange();
    lastSpanX = spanX;

    return true;
}
 
Example 8
Source File: GestureLayout.java    From camerakit-android with MIT License 5 votes vote down vote up
@Override
public boolean onScale(ScaleGestureDetector detector) {
    float dsx = detector.getCurrentSpanX() - detector.getPreviousSpanX();
    float dsy = detector.getCurrentSpanY() - detector.getPreviousSpanY();
    performPinch(dsx, dsy);
    return true;
}
 
Example 9
Source File: GodTouchListener.java    From LChart with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {

    _lastSpanX = detector.getCurrentSpanX();
    _lastSpanY = detector.getCurrentSpanY();

    return true;
}
 
Example 10
Source File: CropOverlayView.java    From Android-Image-Cropper with Apache License 2.0 5 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public boolean onScale(ScaleGestureDetector detector) {
  RectF rect = mCropWindowHandler.getRect();

  float x = detector.getFocusX();
  float y = detector.getFocusY();
  float dY = detector.getCurrentSpanY() / 2;
  float dX = detector.getCurrentSpanX() / 2;

  float newTop = y - dY;
  float newLeft = x - dX;
  float newRight = x + dX;
  float newBottom = y + dY;

  if (newLeft < newRight
      && newTop <= newBottom
      && newLeft >= 0
      && newRight <= mCropWindowHandler.getMaxCropWidth()
      && newTop >= 0
      && newBottom <= mCropWindowHandler.getMaxCropHeight()) {

    rect.set(newLeft, newTop, newRight, newBottom);
    mCropWindowHandler.setRect(rect);
    invalidate();
  }

  return true;
}
 
Example 11
Source File: PinchZoomItemTouchListener.java    From RecyclerViewExtensions with MIT License 5 votes vote down vote up
private float getSpan(ScaleGestureDetector detector) {
    if (mOrientation == LinearLayoutManager.VERTICAL) {
        return detector.getCurrentSpanY();
    } else {
        return detector.getCurrentSpanX();
    }
}
 
Example 12
Source File: ScaleGestureDetectorCompat.java    From EazeGraph with Apache License 2.0 5 votes vote down vote up
/**
 * @see android.view.ScaleGestureDetector#getCurrentSpanX()
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
public static float getCurrentSpanX(ScaleGestureDetector scaleGestureDetector) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        return scaleGestureDetector.getCurrentSpanX();
    } else {
        return scaleGestureDetector.getCurrentSpan();
    }
}
 
Example 13
Source File: GodTouchListener.java    From LChart with Apache License 2.0 4 votes vote down vote up
@Override
        public boolean onScale(ScaleGestureDetector detector) {

            float spanX = detector.getCurrentSpanX();
            float kx = spanX / _lastSpanX;

            float spanY = detector.getCurrentSpanY();
            float ky = spanY / _lastSpanY;

            RectF godRect = _LineChart.get_GodRect();
            RectF mainRect = _LineChart.get_MainPlotRect();

            godRect.right = godRect.left + godRect.width() * kx;// 调整左右(宽,胖)
//            godRect.bottom = godRect.top + godRect.height() * ky;

            constrainRect(godRect, mainRect);

            nofityViewPortChanged(godRect);

            _lastSpanX = spanX;
            _lastSpanY = spanY;

            return true;
        }
 
Example 14
Source File: MainActivity.java    From Chimee with MIT License 4 votes vote down vote up
private boolean isVerticalScaling(ScaleGestureDetector detector) {
    float spanX = detector.getCurrentSpanX();
    float spanY = detector.getCurrentSpanY();
    return spanY > spanX;
}