From 1f47af7826d90bfb035d2e2d331cd775582a331d Mon Sep 17 00:00:00 2001 From: Agnieszka C <85929121+Aga-C@users.noreply.github.com> Date: Tue, 30 Nov 2021 15:55:10 +0100 Subject: [PATCH] Moved handleRotate to the separate method --- .../gallery/pro/adapters/MediaAdapter.kt | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) 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) } }