diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt index 3aec5fc3e..bc01fc36f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/adapters/MediaAdapter.kt @@ -307,36 +307,37 @@ class MediaAdapter( } } - private fun rotateSelection(degrees: Int) { - val paths = getSelectedPaths().filter { it.isImageFast() } + private fun handleRotate(paths: List, degrees: Int) { var fileCnt = paths.size rotatedImagePaths.clear() - val handleRotate = { - activity.toast(R.string.saving) - ensureBackgroundThread { - paths.forEach { - rotatedImagePaths.add(it) - activity.saveRotatedImageToFile(it, it, degrees, true) { - fileCnt-- - if (fileCnt == 0) { - activity.runOnUiThread { - listener?.refreshItems() - finishActMode() - } + activity.toast(R.string.saving) + ensureBackgroundThread { + paths.forEach { + rotatedImagePaths.add(it) + activity.saveRotatedImageToFile(it, it, degrees, true) { + fileCnt-- + if (fileCnt == 0) { + activity.runOnUiThread { + listener?.refreshItems() + finishActMode() } } } } } + } + + private fun rotateSelection(degrees: Int) { + val paths = getSelectedPaths().filter { it.isImageFast() } if (paths.any { activity.needsStupidWritePermissions(it) }) { activity.handleSAFDialog(paths.first { activity.needsStupidWritePermissions(it) }) { if (it) { - handleRotate() + handleRotate(paths, degrees) } } } else { - handleRotate() + handleRotate(paths, degrees) } }