Example #1
0
 @Override
 protected void onZoom(float scale) {
   super.onZoom(scale);
   if (mScaleDetector != null) {
     if (!mScaleDetector.isInProgress()) mCurrentScaleFactor = scale;
   }
 }
Example #2
0
  @Override
  protected void onBitmapChanged(Drawable drawable) {
    super.onBitmapChanged(drawable);

    float v[] = new float[9];
    mSuppMatrix.getValues(v);
    mCurrentScaleFactor = v[Matrix.MSCALE_X];
  }
Example #3
0
  @Override
  protected void onDraw(Canvas canvas) {
    super.onDraw(canvas);
    measureRect();

    if (mDragHandlerPaint == null) {
      return;
    }
    if (mMarginPaint == null) {
      return;
    }
    if (INNER_RECT) {
      canvas.save();
      canvas.drawLine(
          mBitmapRectPoints[0],
          mBitmapRectPoints[1],
          mBitmapRectPoints[2],
          mBitmapRectPoints[3],
          mMarginPaint);
      canvas.drawLine(
          mBitmapRectPoints[4],
          mBitmapRectPoints[5],
          mBitmapRectPoints[6],
          mBitmapRectPoints[7],
          mMarginPaint);
      canvas.drawLine(
          mBitmapRectPoints[0],
          mBitmapRectPoints[1],
          mBitmapRectPoints[4],
          mBitmapRectPoints[5],
          mMarginPaint);
      canvas.drawLine(
          mBitmapRectPoints[2],
          mBitmapRectPoints[3],
          mBitmapRectPoints[6],
          mBitmapRectPoints[7],
          mMarginPaint);
      canvas.drawCircle(mBitmapRectPoints[0], mBitmapRectPoints[1], mRadius, mDragHandlerPaint);
      canvas.drawCircle(mBitmapRectPoints[2], mBitmapRectPoints[3], mRadius, mDragHandlerPaint);
      canvas.drawCircle(mBitmapRectPoints[4], mBitmapRectPoints[5], mRadius, mDragHandlerPaint);
      canvas.drawCircle(mBitmapRectPoints[6], mBitmapRectPoints[7], mRadius, mDragHandlerPaint);
      canvas.restore();
    } else {
      canvas.save();
      canvas.drawRect(mMarginRectF, mMarginPaint);
      canvas.drawCircle(mMarginRectF.left, mMarginRectF.top, mRadius, mDragHandlerPaint);
      canvas.drawCircle(mMarginRectF.right, mMarginRectF.top, mRadius, mDragHandlerPaint);
      canvas.drawCircle(mMarginRectF.left, mMarginRectF.bottom, mRadius, mDragHandlerPaint);
      canvas.drawCircle(mMarginRectF.right, mMarginRectF.bottom, mRadius, mDragHandlerPaint);
      canvas.restore();
    }

    if (!(mDragPoint.x == INVALID_POINT && mDragPoint.y == INVALID_POINT)) {
      canvas.save();
      canvas.drawCircle(mMarginRectF.centerX(), mMarginRectF.centerY(), mRadius, mDragHandlerPaint);
      canvas.restore();
    }
  }
Example #4
0
 @Override
 protected void _setImageDrawable(
     final Drawable drawable,
     final boolean reset,
     final Matrix initial_matrix,
     final float maxZoom) {
   super._setImageDrawable(drawable, reset, initial_matrix, maxZoom);
   mScaleFactor = getMaxZoom() / 3;
 }
Example #5
0
  @Override
  protected void init() {
    super.init();
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mGestureListener = getGestureListener();
    mScaleListener = getScaleListener();

    if (mScaleListener != null) {
      mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener);
    }
    try {
      mGestureDetector = new GestureDetector(getContext(), mGestureListener, null, true);
    } catch (Throwable e) {
    }
    mCurrentScaleFactor = 1f;
    mDoubleTapDirection = 1;
    mRadius = Utils.dip2px(getContext(), RADIUS);
  }