Aperture: QrImageAnalyzer: Fix views interaction on background thread

Change-Id: I962d6cd4589d4f33b29734f8eef6ae45600e464a
diff --git a/app/src/main/java/org/lineageos/aperture/qr/QrImageAnalyzer.kt b/app/src/main/java/org/lineageos/aperture/qr/QrImageAnalyzer.kt
index 2c79aff..4c7ad64 100644
--- a/app/src/main/java/org/lineageos/aperture/qr/QrImageAnalyzer.kt
+++ b/app/src/main/java/org/lineageos/aperture/qr/QrImageAnalyzer.kt
@@ -136,10 +136,7 @@
                     bottomSheetDialogCardView.contentDescription = contentDescription
                     bottomSheetDialogData.movementMethod = null
                     bottomSheetDialogTitle.text = title
-                    scope.launch(Dispatchers.IO) {
-                        val drawable = icon.loadDrawable(activity)!!
-                        bottomSheetDialogIcon.setImageDrawable(drawable)
-                    }
+                    bottomSheetDialogIcon.setImageIcon(icon)
                 }
                 for (action in textClassification.actions.drop(1)) {
                     bottomSheetDialogActionsLayout.addView(inflateButton().apply {
@@ -156,12 +153,14 @@
                         }
                         contentDescription = action.contentDescription
                         this.text = action.title
-                        scope.launch(Dispatchers.IO) {
+                        withContext(Dispatchers.IO) {
                             val drawable = action.icon.loadDrawable(activity)!!
                             drawable.setBounds(0, 0, 15.px, 15.px)
-                            setCompoundDrawables(
-                                drawable, null, null, null
-                            )
+                            withContext(Dispatchers.Main) {
+                                setCompoundDrawables(
+                                    drawable, null, null, null
+                                )
+                            }
                         }
                     })
                 }