Fix UniFile.fromUri() for 2 path segments tree uri
This commit is contained in:
1 parent
556b726349
commit
3978abea87
2 files changed
+8
-2
No files matched your search
@@ -94,6 +94,7 @@ fun DownloadScreen(navigator: DestinationsNavigator) {
|
||||
keepNoMediaFileStatus(downloadLocationState)
|
||||
}
|
||||
}.onFailure {
|
||||
logcat(it)
|
||||
launchSnackBar(cannotGetDownloadLocation)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,10 +33,15 @@ object DocumentsContractApi21 {
|
||||
|
||||
fun createDirectory(self: Uri, displayName: String) = createFile(self, DocumentsContract.Document.MIME_TYPE_DIR, displayName)
|
||||
|
||||
fun prepareTreeUri(treeUri: Uri?): Uri {
|
||||
fun prepareTreeUri(treeUri: Uri): Uri {
|
||||
val documentId = if (treeUri.pathSegments.size == 2) {
|
||||
DocumentsContract.getTreeDocumentId(treeUri)
|
||||
} else {
|
||||
DocumentsContract.getDocumentId(treeUri)
|
||||
}
|
||||
return DocumentsContract.buildDocumentUriUsingTree(
|
||||
treeUri,
|
||||
DocumentsContract.getDocumentId(treeUri),
|
||||
documentId,
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user