mirror of
https://github.com/SimpleMobileTools/Simple-File-Manager.git
synced 2025-06-05 22:09:15 +02:00
use the copytask from filepicker library
This commit is contained in:
@ -7,7 +7,7 @@ import android.view.WindowManager
|
||||
import com.simplemobiletools.filemanager.Config
|
||||
import com.simplemobiletools.filemanager.R
|
||||
import com.simplemobiletools.filemanager.activities.SimpleActivity
|
||||
import com.simplemobiletools.filemanager.asynctasks.CopyTask
|
||||
import com.simplemobiletools.filepicker.asynctasks.CopyMoveTask
|
||||
import com.simplemobiletools.filepicker.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.filepicker.extensions.humanizePath
|
||||
import com.simplemobiletools.filepicker.extensions.isPathOnSD
|
||||
@ -17,7 +17,7 @@ import kotlinx.android.synthetic.main.copy_item.view.*
|
||||
import java.io.File
|
||||
import java.util.*
|
||||
|
||||
class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val copyListener: CopyTask.CopyListener, val listener: OnCopyListener) {
|
||||
class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val copyMoveListener: CopyMoveTask.CopyListener) {
|
||||
|
||||
init {
|
||||
val context = activity
|
||||
@ -79,31 +79,30 @@ class CopyDialog(val activity: SimpleActivity, val files: ArrayList<File>, val c
|
||||
if (view.dialog_radio_group.checkedRadioButtonId == R.id.dialog_radio_copy) {
|
||||
context.toast(R.string.copying)
|
||||
val pair = Pair<ArrayList<File>, File>(files, destinationDir)
|
||||
CopyTask(copyListener, context, false).execute(pair)
|
||||
CopyMoveTask(context, false, config.treeUri, copyMoveListener).execute(pair)
|
||||
dismiss()
|
||||
} else {
|
||||
if (context.isPathOnSD(sourcePath) || context.isPathOnSD(destinationPath)) {
|
||||
context.toast(R.string.moving)
|
||||
val pair = Pair<ArrayList<File>, File>(files, destinationDir)
|
||||
CopyTask(copyListener, context, true).execute(pair)
|
||||
CopyMoveTask(context, true, config.treeUri, copyMoveListener).execute(pair)
|
||||
dismiss()
|
||||
} else {
|
||||
val updatedFiles = ArrayList<File>(files.size * 2)
|
||||
updatedFiles.addAll(files)
|
||||
for (file in files) {
|
||||
val destination = File(destinationDir, file.name)
|
||||
file.renameTo(destination)
|
||||
context.scanFiles(arrayListOf(file, destination)) {}
|
||||
updatedFiles.add(destination)
|
||||
}
|
||||
|
||||
context.scanFiles(updatedFiles) {}
|
||||
context.toast(R.string.moving_success)
|
||||
dismiss()
|
||||
listener.onSuccess()
|
||||
copyMoveListener.copySucceeded(true)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
interface OnCopyListener {
|
||||
fun onSuccess()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user