[Android] Breadcrumb: Catch crash at init time

Geoffrey Métais git at videolan.org
Mon Feb 25 18:53:56 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 25 18:53:00 2019 +0100| [e98de8a6bb55402f055f7a12b48e9f88cdff83ed] | committer: Geoffrey Métais

Breadcrumb: Catch crash at init time

Play Store logs don't permit debugging.
I'm catching this for the time we can properly fix

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

 vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt b/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt
index ce462ace3..c2db9c9e2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/PathAdapter.kt
@@ -1,11 +1,11 @@
 package org.videolan.vlc.gui.browser
 
 import android.net.Uri
-import androidx.collection.SimpleArrayMap
-import androidx.recyclerview.widget.RecyclerView
 import android.view.LayoutInflater
 import android.view.ViewGroup
 import android.widget.TextView
+import androidx.collection.SimpleArrayMap
+import androidx.recyclerview.widget.RecyclerView
 import org.videolan.medialibrary.media.MediaLibraryItem
 import org.videolan.medialibrary.media.MediaWrapper
 import org.videolan.vlc.R
@@ -59,7 +59,10 @@ class PathAdapter(val browser: BaseBrowserFragment, media: MediaWrapper) : Recyc
     }
 
     private fun replaceStoragePath(path: String): String {
-        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))
+        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))
+        } catch (e: IllegalStateException) {
+        }
         return path
     }
 }
\ No newline at end of file



More information about the Android mailing list