make sure we return FileUris in the same order as they were requested

This commit is contained in:
tibbi 2021-12-19 20:55:28 +01:00
parent d0d4b27746
commit 124b7db9b3

View file

@ -930,11 +930,13 @@ fun Context.getFileUrisFromFileDirItems(fileDirItems: List<FileDirItem>): ArrayL
val fileUris = ArrayList<Uri>()
val allIds = getMediaStoreIds(this)
val filePaths = fileDirItems.map { it.path.lowercase(Locale.getDefault()) }
for ((filePath, mediaStoreId) in allIds) {
if (filePaths.contains(filePath.lowercase(Locale.getDefault()))) {
val baseUri = getFileUri(filePath)
val uri = ContentUris.withAppendedId(baseUri, mediaStoreId)
fileUris.add(uri)
filePaths.forEach { path ->
for ((filePath, mediaStoreId) in allIds) {
if (filePath.lowercase() == path) {
val baseUri = getFileUri(filePath)
val uri = ContentUris.withAppendedId(baseUri, mediaStoreId)
fileUris.add(uri)
}
}
}