Skip to content

Commit

Permalink
code cleaning
Browse files Browse the repository at this point in the history
  • Loading branch information
helloyako committed Jan 4, 2017
1 parent 5ad2c22 commit 79ee6fa
Showing 1 changed file with 9 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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());
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 79ee6fa

Please sign in to comment.