From 79ee6fa32fe7e50b98509e99f73bf05d14d10f28 Mon Sep 17 00:00:00 2001 From: helloyako Date: Wed, 4 Jan 2017 20:38:20 +0900 Subject: [PATCH] code cleaning --- .../imagecrop/view/ImageCropView.java | 50 ++++--------------- 1 file changed, 9 insertions(+), 41 deletions(-) diff --git a/imagecropview/src/main/java/com/naver/android/helloyako/imagecrop/view/ImageCropView.java b/imagecropview/src/main/java/com/naver/android/helloyako/imagecrop/view/ImageCropView.java index d50b710..65ccf64 100644 --- a/imagecropview/src/main/java/com/naver/android/helloyako/imagecrop/view/ImageCropView.java +++ b/imagecropview/src/main/java/com/naver/android/helloyako/imagecrop/view/ImageCropView.java @@ -128,6 +128,10 @@ public class ImageCropView extends ImageView { private boolean isChangingScale = false; + private int savedAspectRatioWidth; + private int savedAspectRatioHeight; + private float[] suppMatrixValues = new float[9]; + public ImageCropView(Context context) { this(context, null); } @@ -138,10 +142,10 @@ public ImageCropView(Context context, AttributeSet attrs) { public ImageCropView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - init(context, attrs, defStyle); + init(context, attrs); } - private void init(Context context, AttributeSet attrs, int defStyle) { + private void init(Context context, AttributeSet attrs) { TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCropView); @@ -176,8 +180,8 @@ private void init(Context context, AttributeSet attrs, int defStyle) { a.recycle(); mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); - mGestureListener = getGestureListener(); - mScaleListener = getScaleListener(); + mGestureListener = new GestureListener(); + mScaleListener = new ScaleListener(); mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener); mGestureDetector = new GestureDetector(getContext(), mGestureListener, null, true); @@ -600,24 +604,6 @@ public Matrix getImageViewMatrix(Matrix supportMatrix) { return mDisplayMatrix; } - @Override - public void setImageMatrix(Matrix matrix) { - - Matrix current = getImageMatrix(); - boolean needUpdate = false; - - if (matrix == null && !current.isIdentity() || matrix != null && !current.equals(matrix)) { - needUpdate = true; - } - - super.setImageMatrix(matrix); - - if (needUpdate) onImageMatrixChanged(); - } - - protected void onImageMatrixChanged() { - } - private float baseScale = 1f; protected void getProperBaseMatrix(Drawable drawable, Matrix matrix) { @@ -802,13 +788,9 @@ protected void zoomTo(float scale, float centerX, float centerY) { float oldScale = getScale(); float deltaScale = scale / oldScale; postScale(deltaScale, centerX, centerY); - onZoom(getScale()); center(true, true); } - protected void onZoom(float scale) { - } - protected void onZoomAnimationCompleted(float scale) { if (LOG_ENABLED) { Log.d(LOG_TAG, "onZoomAnimationCompleted. scale: " + scale + ", minZoom: " + getMinScale()); @@ -967,10 +949,6 @@ public void setGridOuterMode(int gridOuterMode) { invalidate(); } - int savedAspectRatioWidth; - int savedAspectRatioHeight; - float[] suppMatrixValues = new float[9]; - public void saveState() { savedAspectRatioWidth = mAspectRatioWidth; savedAspectRatioHeight = mAspectRatioHeight; @@ -1016,14 +994,6 @@ public boolean getDoubleTapEnabled() { return mDoubleTapEnabled; } - protected GestureDetector.OnGestureListener getGestureListener() { - return new GestureListener(); - } - - protected ScaleGestureDetector.OnScaleGestureListener getScaleListener() { - return new ScaleListener(); - } - @Override public boolean onTouchEvent(MotionEvent event) { if (mBitmapChanged) return false; @@ -1117,8 +1087,7 @@ public boolean onDoubleTap(MotionEvent e) { if (mDoubleTapEnabled) { mUserScaled = true; float scale = getScale(); - float targetScale = scale; - targetScale = onDoubleTapPost(scale, getMaxScale()); + float targetScale = onDoubleTapPost(scale, getMaxScale()); targetScale = Math.min(getMaxScale(), Math.max(targetScale, getMinScale())); zoomTo(targetScale, e.getX(), e.getY(), DEFAULT_ANIMATION_DURATION); invalidate(); @@ -1156,7 +1125,6 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve if (e1.getPointerCount() > 1 || e2.getPointerCount() > 1) return false; if (mScaleDetector.isInProgress()) return false; -// if (getScale() == 1f) return false; return ImageCropView.this.onFling(e1, e2, velocityX, velocityY); }