Skip to content

Commit 79ee6fa

Browse files
committed
code cleaning
1 parent 5ad2c22 commit 79ee6fa

File tree

1 file changed

+9
-41
lines changed

1 file changed

+9
-41
lines changed

imagecropview/src/main/java/com/naver/android/helloyako/imagecrop/view/ImageCropView.java

Lines changed: 9 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ public class ImageCropView extends ImageView {
128128

129129
private boolean isChangingScale = false;
130130

131+
private int savedAspectRatioWidth;
132+
private int savedAspectRatioHeight;
133+
private float[] suppMatrixValues = new float[9];
134+
131135
public ImageCropView(Context context) {
132136
this(context, null);
133137
}
@@ -138,10 +142,10 @@ public ImageCropView(Context context, AttributeSet attrs) {
138142

139143
public ImageCropView(Context context, AttributeSet attrs, int defStyle) {
140144
super(context, attrs, defStyle);
141-
init(context, attrs, defStyle);
145+
init(context, attrs);
142146
}
143147

144-
private void init(Context context, AttributeSet attrs, int defStyle) {
148+
private void init(Context context, AttributeSet attrs) {
145149

146150
TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ImageCropView);
147151

@@ -176,8 +180,8 @@ private void init(Context context, AttributeSet attrs, int defStyle) {
176180
a.recycle();
177181

178182
mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
179-
mGestureListener = getGestureListener();
180-
mScaleListener = getScaleListener();
183+
mGestureListener = new GestureListener();
184+
mScaleListener = new ScaleListener();
181185

182186
mScaleDetector = new ScaleGestureDetector(getContext(), mScaleListener);
183187
mGestureDetector = new GestureDetector(getContext(), mGestureListener, null, true);
@@ -600,24 +604,6 @@ public Matrix getImageViewMatrix(Matrix supportMatrix) {
600604
return mDisplayMatrix;
601605
}
602606

603-
@Override
604-
public void setImageMatrix(Matrix matrix) {
605-
606-
Matrix current = getImageMatrix();
607-
boolean needUpdate = false;
608-
609-
if (matrix == null && !current.isIdentity() || matrix != null && !current.equals(matrix)) {
610-
needUpdate = true;
611-
}
612-
613-
super.setImageMatrix(matrix);
614-
615-
if (needUpdate) onImageMatrixChanged();
616-
}
617-
618-
protected void onImageMatrixChanged() {
619-
}
620-
621607
private float baseScale = 1f;
622608

623609
protected void getProperBaseMatrix(Drawable drawable, Matrix matrix) {
@@ -802,13 +788,9 @@ protected void zoomTo(float scale, float centerX, float centerY) {
802788
float oldScale = getScale();
803789
float deltaScale = scale / oldScale;
804790
postScale(deltaScale, centerX, centerY);
805-
onZoom(getScale());
806791
center(true, true);
807792
}
808793

809-
protected void onZoom(float scale) {
810-
}
811-
812794
protected void onZoomAnimationCompleted(float scale) {
813795
if (LOG_ENABLED) {
814796
Log.d(LOG_TAG, "onZoomAnimationCompleted. scale: " + scale + ", minZoom: " + getMinScale());
@@ -967,10 +949,6 @@ public void setGridOuterMode(int gridOuterMode) {
967949
invalidate();
968950
}
969951

970-
int savedAspectRatioWidth;
971-
int savedAspectRatioHeight;
972-
float[] suppMatrixValues = new float[9];
973-
974952
public void saveState() {
975953
savedAspectRatioWidth = mAspectRatioWidth;
976954
savedAspectRatioHeight = mAspectRatioHeight;
@@ -1016,14 +994,6 @@ public boolean getDoubleTapEnabled() {
1016994
return mDoubleTapEnabled;
1017995
}
1018996

1019-
protected GestureDetector.OnGestureListener getGestureListener() {
1020-
return new GestureListener();
1021-
}
1022-
1023-
protected ScaleGestureDetector.OnScaleGestureListener getScaleListener() {
1024-
return new ScaleListener();
1025-
}
1026-
1027997
@Override
1028998
public boolean onTouchEvent(MotionEvent event) {
1029999
if (mBitmapChanged) return false;
@@ -1117,8 +1087,7 @@ public boolean onDoubleTap(MotionEvent e) {
11171087
if (mDoubleTapEnabled) {
11181088
mUserScaled = true;
11191089
float scale = getScale();
1120-
float targetScale = scale;
1121-
targetScale = onDoubleTapPost(scale, getMaxScale());
1090+
float targetScale = onDoubleTapPost(scale, getMaxScale());
11221091
targetScale = Math.min(getMaxScale(), Math.max(targetScale, getMinScale()));
11231092
zoomTo(targetScale, e.getX(), e.getY(), DEFAULT_ANIMATION_DURATION);
11241093
invalidate();
@@ -1156,7 +1125,6 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
11561125

11571126
if (e1.getPointerCount() > 1 || e2.getPointerCount() > 1) return false;
11581127
if (mScaleDetector.isInProgress()) return false;
1159-
// if (getScale() == 1f) return false;
11601128

11611129
return ImageCropView.this.onFling(e1, e2, velocityX, velocityY);
11621130
}

0 commit comments

Comments
 (0)