@@ -128,6 +128,10 @@ public class ImageCropView extends ImageView {
128
128
129
129
private boolean isChangingScale = false ;
130
130
131
+ private int savedAspectRatioWidth ;
132
+ private int savedAspectRatioHeight ;
133
+ private float [] suppMatrixValues = new float [9 ];
134
+
131
135
public ImageCropView (Context context ) {
132
136
this (context , null );
133
137
}
@@ -138,10 +142,10 @@ public ImageCropView(Context context, AttributeSet attrs) {
138
142
139
143
public ImageCropView (Context context , AttributeSet attrs , int defStyle ) {
140
144
super (context , attrs , defStyle );
141
- init (context , attrs , defStyle );
145
+ init (context , attrs );
142
146
}
143
147
144
- private void init (Context context , AttributeSet attrs , int defStyle ) {
148
+ private void init (Context context , AttributeSet attrs ) {
145
149
146
150
TypedArray a = context .obtainStyledAttributes (attrs , R .styleable .ImageCropView );
147
151
@@ -176,8 +180,8 @@ private void init(Context context, AttributeSet attrs, int defStyle) {
176
180
a .recycle ();
177
181
178
182
mTouchSlop = ViewConfiguration .get (getContext ()).getScaledTouchSlop ();
179
- mGestureListener = getGestureListener ();
180
- mScaleListener = getScaleListener ();
183
+ mGestureListener = new GestureListener ();
184
+ mScaleListener = new ScaleListener ();
181
185
182
186
mScaleDetector = new ScaleGestureDetector (getContext (), mScaleListener );
183
187
mGestureDetector = new GestureDetector (getContext (), mGestureListener , null , true );
@@ -600,24 +604,6 @@ public Matrix getImageViewMatrix(Matrix supportMatrix) {
600
604
return mDisplayMatrix ;
601
605
}
602
606
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
-
621
607
private float baseScale = 1f ;
622
608
623
609
protected void getProperBaseMatrix (Drawable drawable , Matrix matrix ) {
@@ -802,13 +788,9 @@ protected void zoomTo(float scale, float centerX, float centerY) {
802
788
float oldScale = getScale ();
803
789
float deltaScale = scale / oldScale ;
804
790
postScale (deltaScale , centerX , centerY );
805
- onZoom (getScale ());
806
791
center (true , true );
807
792
}
808
793
809
- protected void onZoom (float scale ) {
810
- }
811
-
812
794
protected void onZoomAnimationCompleted (float scale ) {
813
795
if (LOG_ENABLED ) {
814
796
Log .d (LOG_TAG , "onZoomAnimationCompleted. scale: " + scale + ", minZoom: " + getMinScale ());
@@ -967,10 +949,6 @@ public void setGridOuterMode(int gridOuterMode) {
967
949
invalidate ();
968
950
}
969
951
970
- int savedAspectRatioWidth ;
971
- int savedAspectRatioHeight ;
972
- float [] suppMatrixValues = new float [9 ];
973
-
974
952
public void saveState () {
975
953
savedAspectRatioWidth = mAspectRatioWidth ;
976
954
savedAspectRatioHeight = mAspectRatioHeight ;
@@ -1016,14 +994,6 @@ public boolean getDoubleTapEnabled() {
1016
994
return mDoubleTapEnabled ;
1017
995
}
1018
996
1019
- protected GestureDetector .OnGestureListener getGestureListener () {
1020
- return new GestureListener ();
1021
- }
1022
-
1023
- protected ScaleGestureDetector .OnScaleGestureListener getScaleListener () {
1024
- return new ScaleListener ();
1025
- }
1026
-
1027
997
@ Override
1028
998
public boolean onTouchEvent (MotionEvent event ) {
1029
999
if (mBitmapChanged ) return false ;
@@ -1117,8 +1087,7 @@ public boolean onDoubleTap(MotionEvent e) {
1117
1087
if (mDoubleTapEnabled ) {
1118
1088
mUserScaled = true ;
1119
1089
float scale = getScale ();
1120
- float targetScale = scale ;
1121
- targetScale = onDoubleTapPost (scale , getMaxScale ());
1090
+ float targetScale = onDoubleTapPost (scale , getMaxScale ());
1122
1091
targetScale = Math .min (getMaxScale (), Math .max (targetScale , getMinScale ()));
1123
1092
zoomTo (targetScale , e .getX (), e .getY (), DEFAULT_ANIMATION_DURATION );
1124
1093
invalidate ();
@@ -1156,7 +1125,6 @@ public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float ve
1156
1125
1157
1126
if (e1 .getPointerCount () > 1 || e2 .getPointerCount () > 1 ) return false ;
1158
1127
if (mScaleDetector .isInProgress ()) return false ;
1159
- // if (getScale() == 1f) return false;
1160
1128
1161
1129
return ImageCropView .this .onFling (e1 , e2 , velocityX , velocityY );
1162
1130
}
0 commit comments