@@ -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