Skip to content

Commit 880573a

Browse files
committed
handle auto-zoom required on size change of the crop image view
1 parent 4c184ba commit 880573a

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

cropper/src/main/java/com/theartofdev/edmodo/cropper/CropImageView.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ public class CropImageView extends FrameLayout {
170170
*/
171171
private RectF mRestoreCropWindowRect;
172172

173+
/**
174+
* Used to detect size change to handle auto-zoom using {@link #handleCropWindowChanged(boolean, boolean)} in
175+
* {@link #layout(int, int, int, int)}.
176+
*/
177+
private boolean mSizeChanged;
178+
173179
/**
174180
* Task used to load bitmap async from UI thread
175181
*/
@@ -1258,6 +1264,9 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
12581264
handleCropWindowChanged(false, false);
12591265
mCropOverlayView.fixCurrentCropWindowRect();
12601266
mRestoreCropWindowRect = null;
1267+
} else if (mSizeChanged) {
1268+
mSizeChanged = false;
1269+
handleCropWindowChanged(false, false);
12611270
}
12621271
} else {
12631272
updateImageBounds(true);
@@ -1267,6 +1276,16 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
12671276
}
12681277
}
12691278

1279+
/**
1280+
* Detect size change to handle auto-zoom using {@link #handleCropWindowChanged(boolean, boolean)} in
1281+
* {@link #layout(int, int, int, int)}.
1282+
*/
1283+
@Override
1284+
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
1285+
super.onSizeChanged(w, h, oldw, oldh);
1286+
mSizeChanged = oldw > 0 && oldh > 0;
1287+
}
1288+
12701289
/**
12711290
* Handle crop window change to:<br>
12721291
* 1. Execute auto-zoom-in/out depending on the area covered of cropping window relative to the

0 commit comments

Comments
 (0)