From 726e7c1649dce3877202a6f689fb17185a07b26c Mon Sep 17 00:00:00 2001 From: Naveen Date: Wed, 24 May 2023 02:31:14 +0530 Subject: [PATCH] Do processing on background thread --- .../gallery/pro/extensions/Activity.kt | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 09119dd97..1fdecf9e6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -774,18 +774,22 @@ fun BaseSimpleActivity.ensureWriteAccess(path: String, callback: () -> Unit) { @TargetApi(Build.VERSION_CODES.N) fun BaseSimpleActivity.launchResizeMultipleImagesDialog(paths: List, callback: (() -> Unit)? = null) { - val imagePaths = mutableListOf() - val imageSizes = mutableListOf() - for (path in paths) { - val size = path.getImageResolution(this) - if (size != null) { - imagePaths.add(path) - imageSizes.add(size) + ensureBackgroundThread { + val imagePaths = mutableListOf() + val imageSizes = mutableListOf() + for (path in paths) { + val size = path.getImageResolution(this) + if (size != null) { + imagePaths.add(path) + imageSizes.add(size) + } } - } - ResizeMultipleImagesDialog(this, imagePaths, imageSizes) { - callback?.invoke() + runOnUiThread { + ResizeMultipleImagesDialog(this, imagePaths, imageSizes) { + callback?.invoke() + } + } } }