refresh the folder list after creating a new item

This commit is contained in:
tibbi 2017-01-07 14:20:50 +01:00
parent a162805068
commit 18b0530ecd
2 changed files with 7 additions and 3 deletions

View file

@ -11,7 +11,7 @@ import com.simplemobiletools.commons.helpers.BaseConfig
import kotlinx.android.synthetic.main.dialog_create_new_folder.view.*
import java.io.File
class CreateNewFolderDialog(val context: Context, val path: String) {
class CreateNewFolderDialog(val context: Context, val path: String, val callback: () -> Unit) {
init {
val view = LayoutInflater.from(context).inflate(R.layout.dialog_create_new_folder, null)
@ -33,6 +33,7 @@ class CreateNewFolderDialog(val context: Context, val path: String) {
}
if (createDirectory(file)) {
callback.invoke()
dismiss()
} else {
context.toast(R.string.error_occurred)
@ -50,6 +51,7 @@ class CreateNewFolderDialog(val context: Context, val path: String) {
val documentFile = context.getFileDocument(file.absolutePath, BaseConfig.newInstance(context).treeUri)
documentFile.createDirectory(file.name)
true
} else file.mkdirs()
} else
file.mkdirs()
}
}

View file

@ -105,7 +105,9 @@ class FilePickerDialog(val context: Context,
private fun getTitle() = if (pickFile) R.string.select_file else R.string.select_folder
private fun createNewFolder() {
CreateNewFolderDialog(context, currPath)
CreateNewFolderDialog(context, currPath) {
updateItems()
}
}
private fun updateItems() {