diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt index 08056c4fb..67497269f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt @@ -13,11 +13,13 @@ import java.io.File import java.util.* open class SimpleActivity : BaseSimpleActivity() { + var copyMoveCallback: (() -> Unit)? = null override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) } - protected fun copyMoveFilesTo(source: String, files: ArrayList, isCopyOperation: Boolean, copyMoveListener: CopyMoveTask.CopyMoveListener) { + protected fun copyMoveFilesTo(source: String, files: ArrayList, isCopyOperation: Boolean, callback: () -> Unit) { + copyMoveCallback = callback val currPath = source.trimEnd('/') PickAlbumDialog(this, currPath) { val destinationFolder = File(it) @@ -69,4 +71,21 @@ open class SimpleActivity : BaseSimpleActivity() { } } } + + private val copyMoveListener = object : CopyMoveTask.CopyMoveListener { + override fun copySucceeded(copyOnly: Boolean, copiedAll: Boolean) { + if (copyOnly) { + toast(if (copiedAll) R.string.copying_success else R.string.copying_success_partial) + } else { + toast(if (copiedAll) R.string.moving_success else R.string.moving_success_partial) + } + copyMoveCallback?.invoke() + copyMoveCallback = null + } + + override fun copyFailed() { + toast(R.string.copy_move_failed) + copyMoveCallback = null + } + } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt index aa47b6de2..556a49eaa 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -18,7 +18,6 @@ import android.util.DisplayMetrics import android.view.Menu import android.view.MenuItem import android.view.View -import com.simplemobiletools.commons.asynctasks.CopyMoveTask import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.PropertiesDialog import com.simplemobiletools.commons.dialogs.RenameItemDialog @@ -188,22 +187,11 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View private fun copyMoveTo(isCopyOperation: Boolean) { val currPath = File(getCurrentPath()).parent.trimEnd('/') val files = ArrayList(1).apply { add(getCurrentFile()) } - copyMoveFilesTo(currPath, files, isCopyOperation, copyMoveListener) - } - - private val copyMoveListener = object : CopyMoveTask.CopyMoveListener { - override fun copySucceeded(copyOnly: Boolean, copiedAll: Boolean) { - if (copyOnly) { - toast(if (copiedAll) R.string.copying_success else R.string.copying_success_partial) - } else { + copyMoveFilesTo(currPath, files, isCopyOperation) { + if (!isCopyOperation) { reloadViewPager() - toast(if (copiedAll) R.string.moving_success else R.string.moving_success_partial) } } - - override fun copyFailed() { - toast(R.string.copy_move_failed) - } } private fun saveImageAs() {