diff --git a/CHANGELOG.md b/CHANGELOG.md index 048d390b..48d9f14c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Added - CropImage.getActivityResult(data).getBitmap(context) [#49](https://github.com/CanHub/Android-Image-Cropper/issues/49) +### Fixed +- CropImageView incorrectly restored on rotation [#68](https://github.com/CanHub/Android-Image-Cropper/issues/68) + ## [2.1.0] - 11/02/21 ### Changed - From Java to Kotlin: [CropImageOptions](https://github.com/CanHub/Android-Image-Cropper/issues/40), [CropWindowHandler](https://github.com/CanHub/Android-Image-Cropper/issues/37) diff --git a/cropper/src/main/java/com/canhub/cropper/CropImageView.java b/cropper/src/main/java/com/canhub/cropper/CropImageView.java index e665b9c8..b3795429 100644 --- a/cropper/src/main/java/com/canhub/cropper/CropImageView.java +++ b/cropper/src/main/java/com/canhub/cropper/CropImageView.java @@ -1022,8 +1022,6 @@ public void setImageUriAsync(Uri uri) { // either no existing task is working or we canceled it, need to load new URI clearImageInt(); - mRestoreCropWindowRect = null; - mRestoreDegreesRotated = 0; mCropOverlayView.setInitialCropWindowRect(null); mBitmapLoadingWorkerJob = new WeakReference<>(new BitmapLoadingWorkerJob((FragmentActivity)getContext(),this, uri)); mBitmapLoadingWorkerJob.get().start(); @@ -1236,6 +1234,8 @@ private void clearImageInt() { mZoomOffsetY = 0; mImageMatrix.reset(); mSaveInstanceStateBitmapUri = null; + mRestoreCropWindowRect = null; + mRestoreDegreesRotated = 0; mImageView.setImageBitmap(null); @@ -1527,6 +1527,7 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) { if (mRestoreDegreesRotated != mInitialDegreesRotated) { mDegreesRotated = mRestoreDegreesRotated; applyImageMatrix(r - l, b - t, true, false); + mRestoreDegreesRotated = 0; } mImageMatrix.mapRect(mRestoreCropWindowRect); mCropOverlayView.setCropWindowRect(mRestoreCropWindowRect);