From a963a13fc7241f233dc611c8994916dd4dba8dd2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 1 Apr 2017 18:08:49 +0200 Subject: [PATCH] get the source path at copy/move from the first item --- .../gallery/activities/SimpleActivity.kt | 8 +++++++- .../gallery/activities/ViewPagerActivity.kt | 3 +-- 2 files changed, 8 insertions(+), 3 deletions(-) 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 67497269f..1fa335065 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/SimpleActivity.kt @@ -18,8 +18,14 @@ open class SimpleActivity : BaseSimpleActivity() { super.onCreate(savedInstanceState) } - protected fun copyMoveFilesTo(source: String, files: ArrayList, isCopyOperation: Boolean, callback: () -> Unit) { + fun copyMoveFilesTo(files: ArrayList, isCopyOperation: Boolean, callback: () -> Unit) { + if (files.isEmpty()) { + toast(R.string.unknown_error_occurred) + return + } + copyMoveCallback = callback + val source = if (files[0].isFile) files[0].parent.trimEnd('/') else files[0].absolutePath val currPath = source.trimEnd('/') PickAlbumDialog(this, currPath) { val destinationFolder = File(it) 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 556a49eaa..57767dcf5 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/ViewPagerActivity.kt @@ -185,9 +185,8 @@ 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) { + copyMoveFilesTo(files, isCopyOperation) { if (!isCopyOperation) { reloadViewPager() }