refresh the folder list after creating a new item
This commit is contained in:
parent
a162805068
commit
18b0530ecd
2 changed files with 7 additions and 3 deletions
|
@ -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()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() {
|
||||
|
|
Loading…
Reference in a new issue