Mercurial > cgi-bin > hgweb.cgi > SimpleResizer
changeset 21:7e7e71724770
No longer breaks when phone rotated.
author | David Barts <n5jrn@me.com> |
---|---|
date | Mon, 22 Feb 2021 17:49:27 -0800 |
parents | 21be543e9127 |
children | c29f941d09cd |
files | app/src/main/java/com/bartsent/simpleresizer/EditImage.kt app/src/main/res/values/strings.xml |
diffstat | 2 files changed, 8 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- 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 {
--- 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 @@ <string name="error_io">I/O error.</string> <string name="error_no_uri">No URI supplied, and no remembered image!</string> <string name="error_save_bitmap">Failed to save bitmap.</string> - <string name="image_size_text">Width: %d, Height: %d.</string> + <string name="image_size_text">%d ✕ %d</string> <string name="ok_text">OK</string> <string name="r_180">180˚</string> <string name="r_90_ccw">90˚ CCW</string>