[Android] The smallest valid bound argument to Random.nextInt() is 1

Robert Stone git at videolan.org
Tue Feb 23 05:21:57 UTC 2021


vlc-android | branch: master | Robert Stone <rhstone at gmail.com> | Mon Feb 15 23:07:40 2021 -0800| [2792ebcc850b52b9ec294c5d9a190911d9765156] | committer: Nicolas Pomepuy

The smallest valid bound argument to Random.nextInt() is 1

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

 .../vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt       | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt b/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt
index 24e0b712c..0703ed131 100644
--- a/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt
+++ b/application/vlc-android/src/org/videolan/vlc/media/MediaSessionBrowser.kt
@@ -243,7 +243,7 @@ class MediaSessionBrowser : ExtensionManagerActivity {
                         /* Shuffle All */
                         val audioCount = ml.audioCount
                         /* Show cover art from the whole library */
-                        val offset = Random().nextInt((audioCount - MAX_COVER_ART_ITEMS).coerceAtLeast(0))
+                        val offset = Random().nextInt((audioCount - MAX_COVER_ART_ITEMS).coerceAtLeast(1))
                         val allAudio = ml.getPagedAudio(Medialibrary.SORT_ALPHA, false, MAX_COVER_ART_ITEMS, offset)
                         val shuffleAllCover: Bitmap? = getHomeImage(context, "shuffleAll", allAudio)
                         val shuffleAllMediaDesc = getPlayAllBuilder(res, ID_SHUFFLE_ALL, audioCount, shuffleAllCover)



More information about the Android mailing list