store the real destination path in a variable

This commit is contained in:
tibbi 2016-11-09 21:19:46 +01:00
parent d6fd4ad378
commit d7ffc35dd0

View file

@ -22,12 +22,14 @@ class CopyDialog(val activity: Activity, val files: List<File>, val copyListener
val context = activity
val view = LayoutInflater.from(context).inflate(R.layout.copy_item, null)
val path = files[0].parent.trimEnd('/')
var destinationPath = ""
view.source.text = context.humanizePath(path)
view.destination.setOnClickListener {
PickAlbumDialog(activity, object : PickAlbumDialog.OnPickAlbumListener {
override fun onSuccess(path: String) {
destinationPath = path
view.destination.text = context.humanizePath(path)
}
})
@ -42,8 +44,7 @@ class CopyDialog(val activity: Activity, val files: List<File>, val copyListener
window!!.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE)
show()
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
val destinationPath = view.destination.value
if (destinationPath == context.resources.getString(R.string.select_destination)) {
if (destinationPath == context.resources.getString(R.string.select_destination) || destinationPath.isEmpty()) {
context.toast(R.string.please_select_destination)
return@setOnClickListener
}