[Android] Fix PathOperation crash

Nicolas Pomepuy git at videolan.org
Wed Sep 30 07:24:01 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Sep 29 14:44:25 2020 +0200| [cb3faedd2eb8d4145a6170122f4d95f3c126bad5] | committer: Nicolas Pomepuy

Fix PathOperation crash

> https://code.videolan.org/videolan/vlc-android/commit/cb3faedd2eb8d4145a6170122f4d95f3c126bad5
---

 .../src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt  | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt
index 3ee1e97d1..c0ef12b64 100644
--- a/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt
+++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/browser/PathOperationDelegate.kt
@@ -43,7 +43,7 @@ class PathOperationDelegate : IPathOperationDelegate {
      */
     override fun appendPathToUri(path: String, uri: Uri.Builder) {
         var newPath = path
-        for (i in 0..storages.size()) if (storages.valueAt(i) == newPath) newPath = storages.keyAt(i)
+        for (i in 0 until storages.size()) if (storages.valueAt(i) == newPath) newPath = storages.keyAt(i)
         newPath.split('/').forEach {
             uri.appendPath(it)
         }
@@ -57,7 +57,7 @@ class PathOperationDelegate : IPathOperationDelegate {
      */
     override fun replaceStoragePath(path: String): String {
         try {
-            if (storages.size() > 0) for (i in 0..storages.size()) if (path.startsWith(storages.keyAt(i))) return path.replace(storages.keyAt(i), storages.valueAt(i))
+            if (storages.size() > 0) for (i in 0 until storages.size()) if (path.startsWith(storages.keyAt(i))) return path.replace(storages.keyAt(i), storages.valueAt(i))
         } catch (e: IllegalStateException) {
         }
         return path



More information about the Android mailing list