# HG changeset patch # User David Barts # Date 1614044967 28800 # Node ID 7e7e717247707dd394046281be5cb1327dbe376b # Parent 21be543e91271b64439f67d58a170bfe104d5eed No longer breaks when phone rotated. diff -r 21be543e9127 -r 7e7e71724770 app/src/main/java/com/bartsent/simpleresizer/EditImage.kt --- a/app/src/main/java/com/bartsent/simpleresizer/EditImage.kt Mon Feb 22 17:20:40 2021 -0800 +++ b/app/src/main/java/com/bartsent/simpleresizer/EditImage.kt Mon Feb 22 17:49:27 2021 -0800 @@ -106,7 +106,7 @@ return } - // Being stateful stops data loss when the phone gets rotated. + // User has opened a new image. if (imageUri != State.uri) { State.uri = imageUri binding.progressBar.visibility = ProgressBar.VISIBLE @@ -122,7 +122,13 @@ setImage(State.bitmap!!) } } + return } + + // Rotation (of the phone). + val oldBitmap = State.bitmap + if (oldBitmap != null) + setImage(oldBitmap) } private fun setImage(image: Bitmap): Unit { diff -r 21be543e9127 -r 7e7e71724770 app/src/main/res/values/strings.xml --- a/app/src/main/res/values/strings.xml Mon Feb 22 17:20:40 2021 -0800 +++ b/app/src/main/res/values/strings.xml Mon Feb 22 17:49:27 2021 -0800 @@ -11,7 +11,7 @@ I/O error. No URI supplied, and no remembered image! Failed to save bitmap. - Width: %d, Height: %d. + %d ✕ %d OK 180˚ 90˚ CCW