Do processing on background thread

This commit is contained in:
Naveen 2023-05-24 02:31:14 +05:30
parent ce898ba1cc
commit 726e7c1649

View file

@ -774,18 +774,22 @@ fun BaseSimpleActivity.ensureWriteAccess(path: String, callback: () -> Unit) {
@TargetApi(Build.VERSION_CODES.N)
fun BaseSimpleActivity.launchResizeMultipleImagesDialog(paths: List<String>, callback: (() -> Unit)? = null) {
val imagePaths = mutableListOf<String>()
val imageSizes = mutableListOf<Point>()
for (path in paths) {
val size = path.getImageResolution(this)
if (size != null) {
imagePaths.add(path)
imageSizes.add(size)
ensureBackgroundThread {
val imagePaths = mutableListOf<String>()
val imageSizes = mutableListOf<Point>()
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()
}
}
}
}