wrap folder creating on a try/catch block, report errors
This commit is contained in:
parent
b1d184df97
commit
e7baf84fe7
1 changed files with 16 additions and 10 deletions
|
@ -41,18 +41,24 @@ class CreateNewFolderDialog(val activity: BaseSimpleActivity, val path: String,
|
|||
}
|
||||
|
||||
private fun createFolder(file: File, alertDialog: AlertDialog) {
|
||||
if (activity.needsStupidWritePermissions(file.absolutePath)) {
|
||||
activity.handleSAFDialog(file) {
|
||||
try {
|
||||
val documentFile = activity.getFileDocument(file.absolutePath)
|
||||
documentFile?.createDirectory(file.name)
|
||||
sendSuccess(alertDialog, file)
|
||||
} catch (e: SecurityException) {
|
||||
activity.showErrorToast(e)
|
||||
try {
|
||||
if (activity.needsStupidWritePermissions(file.absolutePath)) {
|
||||
activity.handleSAFDialog(file) {
|
||||
try {
|
||||
val documentFile = activity.getFileDocument(file.absolutePath)
|
||||
documentFile?.createDirectory(file.name)
|
||||
sendSuccess(alertDialog, file)
|
||||
} catch (e: SecurityException) {
|
||||
activity.showErrorToast(e)
|
||||
}
|
||||
}
|
||||
} else if (file.mkdirs()) {
|
||||
sendSuccess(alertDialog, file)
|
||||
} else {
|
||||
activity.toast(R.string.unknown_error_occurred)
|
||||
}
|
||||
} else if (file.mkdirs()) {
|
||||
sendSuccess(alertDialog, file)
|
||||
} catch (e: Exception) {
|
||||
activity.showErrorToast(e)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue