add the copy move dialog

This commit is contained in:
tibbi 2017-04-01 17:09:24 +02:00
parent 9a0cde9796
commit 57a0baa253

View file

@ -180,24 +180,16 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
private fun copyTo() { private fun copyTo() {
val copyMoveListener = object : CopyMoveTask.CopyMoveListener { copyMoveTo(true)
override fun copySucceeded(copyOnly: Boolean, copiedAll: Boolean) { }
if (copyOnly) {
toast(if (copiedAll) R.string.copying_success else R.string.copying_success_partial)
} else {
reloadViewPager()
toast(if (copiedAll) R.string.moving_success else R.string.moving_success_partial)
}
}
override fun copyFailed() { private fun moveTo() {
toast(R.string.copy_move_failed) copyMoveTo(false)
} }
}
private fun copyMoveTo(isCopyOperation: Boolean) {
val currPath = File(getCurrentPath()).parent.trimEnd('/') val currPath = File(getCurrentPath()).parent.trimEnd('/')
val files = ArrayList<File>(1).apply { add(getCurrentFile()) } val files = ArrayList<File>(1).apply { add(getCurrentFile()) }
val isCopyOperation = true
PickAlbumDialog(this, currPath) { PickAlbumDialog(this, currPath) {
val destinationFolder = File(it) val destinationFolder = File(it)
@ -222,13 +214,13 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
if (isCopyOperation) { if (isCopyOperation) {
toast(R.string.copying) toast(R.string.copying)
val pair = Pair<ArrayList<File>, File>(files, destinationFolder) val pair = Pair<ArrayList<File>, File>(files, destinationFolder)
CopyMoveTask(this, false, true, copyMoveListener).execute(pair) CopyMoveTask(this, isCopyOperation, true, copyMoveListener).execute(pair)
} else { } else {
if (isPathOnSD(currPath) || isPathOnSD(destinationFolder.absolutePath)) { if (isPathOnSD(currPath) || isPathOnSD(destinationFolder.absolutePath)) {
handleSAFDialog(files[0]) { handleSAFDialog(files[0]) {
toast(R.string.moving) toast(R.string.moving)
val pair = Pair<ArrayList<File>, File>(files, destinationFolder) val pair = Pair<ArrayList<File>, File>(files, destinationFolder)
CopyMoveTask(this, true, true, copyMoveListener).execute(pair) CopyMoveTask(this, isCopyOperation, true, copyMoveListener).execute(pair)
} }
} else { } else {
val updatedFiles = ArrayList<File>(files.size * 2) val updatedFiles = ArrayList<File>(files.size * 2)
@ -250,8 +242,19 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
} }
} }
private fun moveTo() { 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 {
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() { private fun saveImageAs() {