revert a part of getFileDocument, add another check
This commit is contained in:
parent
8b60ef6e75
commit
e1215e7b0e
2 changed files with 9 additions and 20 deletions
|
@ -29,7 +29,7 @@ ext {
|
|||
propMinSdkVersion = 16
|
||||
propTargetSdkVersion = propCompileSdkVersion
|
||||
propVersionCode = 1
|
||||
propVersionName = '2.23.4'
|
||||
propVersionName = '2.23.6'
|
||||
kotlin_version = '1.1.3-2'
|
||||
support_libs = '25.3.1'
|
||||
}
|
||||
|
|
|
@ -351,25 +351,14 @@ fun BaseSimpleActivity.getFileDocument(path: String): DocumentFile? {
|
|||
|
||||
var document = DocumentFile.fromTreeUri(this, Uri.parse(baseConfig.treeUri))
|
||||
val parts = relativePath.split("/")
|
||||
for (i in 0..parts.size - 1) {
|
||||
var currDocument = document.findFile(parts[i])
|
||||
if (currDocument != null) {
|
||||
for (part in parts) {
|
||||
val currDocument = document.findFile(part)
|
||||
if (currDocument != null)
|
||||
document = currDocument
|
||||
} else {
|
||||
// We need to assure that we transverse to the right directory!
|
||||
if (i == parts.size - 1) {
|
||||
// The last document should be the file we're looking for, not a directory
|
||||
currDocument = document.createFile("", parts[i])
|
||||
} else {
|
||||
currDocument = document.createDirectory(parts[i])
|
||||
}
|
||||
|
||||
if (currDocument == null) {
|
||||
toast(R.string.unknown_error_occurred)
|
||||
return null
|
||||
}
|
||||
document = currDocument
|
||||
}
|
||||
}
|
||||
return document
|
||||
|
||||
return if (document.name == path.getFilenameFromPath())
|
||||
document
|
||||
else
|
||||
null
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue