[Android] Fix ArrayIndexOutOfBoundsException on audio tab restauration

Nicolas Pomepuy git at videolan.org
Thu May 7 12:17:13 CEST 2020


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Tue May  5 11:41:37 2020 +0200| [a43a79e55ed350c45f6b9862a3959124461f6818] | committer: Nicolas Pomepuy

Fix ArrayIndexOutOfBoundsException on audio tab restauration

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

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

diff --git a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
index 70ab43ae6..3d91ecfe7 100644
--- a/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
+++ b/application/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.kt
@@ -190,7 +190,7 @@ class AudioBrowserFragment : BaseAudioBrowser<AudioBrowserViewModel>() {
     }
 
     private fun setupProvider(index: Int = viewModel.currentTab) {
-        val provider = viewModel.providers[index]
+        val provider = viewModel.providers[index.coerceIn(0, viewModel.providers.size-1)]
         if (provider.loading.hasObservers()) return
         provider.pagedList.observe(viewLifecycleOwner, Observer { items ->
             @Suppress("UNCHECKED_CAST")



More information about the Android mailing list