Skip to content
Snippets Groups Projects
Commit 40579537 authored by Nicolas Pomepuy's avatar Nicolas Pomepuy
Browse files

Fix NullPointerException whe deleting files

parent 0efa9402
No related branches found
No related tags found
1 merge request!215Fixes for beta
......@@ -323,19 +323,22 @@ object FileUtils {
@WorkerThread
fun findFile(uri: Uri): DocumentFile? {
val storage = getMediaStorage(uri)
val treePref = Settings.getInstance(VLCApplication.appContext).getString("tree_uri_" + storage!!, null)
?: return null
val treeUri = Uri.parse(treePref)
var documentFile = DocumentFile.fromTreeUri(VLCApplication.appContext, treeUri)
val parts = uri.path.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
for (i in 3 until parts.size) {
if (documentFile != null)
documentFile = documentFile.findFile(parts[i])
else
return null
uri.path?.let { path ->
val storage = getMediaStorage(uri)
val treePref = Settings.getInstance(VLCApplication.appContext).getString("tree_uri_" + storage!!, null)
?: return null
val treeUri = Uri.parse(treePref)
var documentFile = DocumentFile.fromTreeUri(VLCApplication.appContext, treeUri)
val parts = path.split("/".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()
for (i in 3 until parts.size) {
if (documentFile != null)
documentFile = documentFile.findFile(parts[i])
else
return null
}
return documentFile
}
return documentFile
return null
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment