Skip to content

Commit d566d63

Browse files
committed
fix restore state not restoring rotation
1 parent 515f986 commit d566d63

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ For more information, see the [GitHub Wiki](https://github.com/ArthurHub/Android
123123
*2.4.3* (WIP)
124124

125125
- Adding option to omit camera intents on getPickImageChooserIntent (thx Hugo Rossi)
126+
- Fix restore state not restoring rotation
126127

127128
*2.4.2*
128129

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ public class CropImageView extends FrameLayout {
181181
*/
182182
private RectF mRestoreCropWindowRect;
183183

184+
/**
185+
* Used to restore image rotation after state restore
186+
*/
187+
private int mRestoreDegreesRotated;
188+
184189
/**
185190
* Used to detect size change to handle auto-zoom using {@link #handleCropWindowChanged(boolean, boolean)} in
186191
* {@link #layout(int, int, int, int)}.
@@ -1213,7 +1218,7 @@ public void onRestoreInstanceState(Parcelable state) {
12131218
}
12141219
}
12151220

1216-
mDegreesRotated = bundle.getInt("DEGREES_ROTATED");
1221+
mDegreesRotated = mRestoreDegreesRotated = bundle.getInt("DEGREES_ROTATED");
12171222

12181223
Rect initialCropRect = bundle.getParcelable("INITIAL_CROP_RECT");
12191224
if (initialCropRect != null && (initialCropRect.width() > 0 || initialCropRect.height() > 0)) {
@@ -1315,6 +1320,10 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
13151320

13161321
// after state restore we want to restore the window crop, possible only after widget size is known
13171322
if (mRestoreCropWindowRect != null) {
1323+
if (mRestoreDegreesRotated != mInitialDegreesRotated) {
1324+
mDegreesRotated = mRestoreDegreesRotated;
1325+
applyImageMatrix(r - l, b - t, true, false);
1326+
}
13181327
mImageMatrix.mapRect(mRestoreCropWindowRect);
13191328
mCropOverlayView.setCropWindowRect(mRestoreCropWindowRect);
13201329
handleCropWindowChanged(false, false);

0 commit comments

Comments
 (0)