changeset 31:0023e6013dd9

Complete the deception that is my dummy main activity (hopefully).
author David Barts <n5jrn@me.com>
date Fri, 26 Feb 2021 13:24:30 -0800
parents aacf7a856b5f
children be08576794af
files app/src/main/java/com/bartsent/simpleresizer/MainActivity.kt
diffstat 1 files changed, 14 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/app/src/main/java/com/bartsent/simpleresizer/MainActivity.kt	Wed Feb 24 19:14:50 2021 -0800
+++ b/app/src/main/java/com/bartsent/simpleresizer/MainActivity.kt	Fri Feb 26 13:24:30 2021 -0800
@@ -23,17 +23,14 @@
 
     override fun onResume() {
         super.onResume()
-        if (showChooser)
-            doShowChooser()
-        else
+        if (showChooser) {
+            Intent(Intent.ACTION_GET_CONTENT).run {
+                type = "image/*"
+                addCategory(Intent.CATEGORY_OPENABLE)
+                startActivityForResult(this, GET_IMAGE)
+            }
+        } else {
             showChooser = true
-    }
-
-    fun doShowChooser(): Unit {
-        Intent(Intent.ACTION_GET_CONTENT).run {
-            type = "image/*"
-            addCategory(Intent.CATEGORY_OPENABLE)
-            startActivityForResult(this, GET_IMAGE)
         }
     }
 
@@ -46,10 +43,13 @@
                 Intent(Intent.ACTION_SEND, imageUri, this, EditImage::class.java).run {
                     startActivity(this)
                 }
-            } else {
-                Toast.makeText(applicationContext, "Unable to get image!", Toast.LENGTH_LONG).show()
-                doShowChooser()
+                return
             }
         }
+        // If we get here, it means that the user backed out of the file chooser.
+        // This should be interpreted as a desire to back out of editing an image
+        // altogether. So… goodbye!
+        showChooser = true  // reset flag (paranoid)
+        finish()
     }
-}
\ No newline at end of file
+}