[Android] Paged modles: prevent IndexOutOfBoundsException

Geoffrey Métais git at videolan.org
Fri Feb 15 14:28:12 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 15 13:26:20 2019 +0100| [3c308a58f86482f2f48cf82cee59a4acf4bdc776] | committer: Geoffrey Métais

Paged modles: prevent IndexOutOfBoundsException

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

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

diff --git a/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt b/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
index 1d6cf45f3..89fff12c9 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
@@ -110,7 +110,7 @@ abstract class MLPagedModel<T : MediaLibraryItem>(context: Context) : SortableMo
         for ((position, item) in list.withIndex()) {
             val previous = when {
                 position > 0 -> list[position-1]
-                startposition > 0 -> pagedList.value?.get(startposition+position-1)
+                startposition > 0 -> pagedList.value?.getOrNull(startposition+position-1)
                 else -> null
             }
             ModelsHelper.getHeader(context, sort, item, previous)?.let {



More information about the Android mailing list