[Android] Fix ArrayIndexOutOfBoundsException in extractSingles

Nicolas Pomepuy git at videolan.org
Wed Sep 2 09:41:28 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue Sep  1 12:15:17 2020 +0200| [d70f7a79cb6dee2086366e52183fb845772c9078] | committer: Nicolas Pomepuy

Fix ArrayIndexOutOfBoundsException in extractSingles

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

 .../src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt
index 94c0ce08c..853baa5a5 100644
--- a/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt
+++ b/application/vlc-android/src/org/videolan/vlc/providers/medialibrary/VideoGroupsProvider.kt
@@ -28,5 +28,5 @@ class VideoGroupsProvider(context: Context, model: SortableModel) : Medialibrary
 }
 
 private fun Array<VideoGroup>.extractSingles() = map {
-    if (it.mediaCount() == 1) it.media(Medialibrary.SORT_DEFAULT, false, 1, 0)[0] else it
+    if (it.mediaCount() == 1) it.media(Medialibrary.SORT_DEFAULT, false, 1, 0).getOrNull(0) ?: it else it
 }.toTypedArray()
\ No newline at end of file



More information about the Android mailing list