[Android] Medialibrary: Catch UnsupportedOperationException

Geoffrey Métais git at videolan.org
Tue Jan 29 13:07:55 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 29 12:11:11 2019 +0100| [7c53b343db84c8f21a48669a86985342aa5524c3] | committer: Geoffrey Métais

Medialibrary: Catch UnsupportedOperationException

Workaround for crash on 1+ devices. Wrong implementation of ListIterator
seems to be used.

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

 vlc-android/src/org/videolan/vlc/util/Kextensions.kt | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/util/Kextensions.kt b/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
index 814234c50..3e2fcab28 100644
--- a/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
+++ b/vlc-android/src/org/videolan/vlc/util/Kextensions.kt
@@ -104,16 +104,18 @@ fun List<MediaWrapper>.getWithMLMeta() : List<MediaWrapper> {
 fun MutableList<MediaWrapper>.updateWithMLMeta() : MutableList<MediaWrapper> {
     val iter = listIterator()
     val ml = VLCApplication.getMLInstance()
-    while (iter.hasNext()) {
-        val media = iter.next()
-        if (media.id == 0L) {
-            val mw = ml.findMedia(media)
-            if (mw!!.id != 0L) {
-                if (mw.type == MediaWrapper.TYPE_ALL) mw.type = media.getType()
-                iter.set(mw)
+    try {
+        while (iter.hasNext()) {
+            val media = iter.next()
+            if (media.id == 0L) {
+                val mw = ml.findMedia(media)
+                if (mw!!.id != 0L) {
+                    if (mw.type == MediaWrapper.TYPE_ALL) mw.type = media.getType()
+                    iter.set(mw)
+                }
             }
         }
-    }
+    } catch (ignored: Exception) {}
     return this
 }
 



More information about the Android mailing list