[Android] Fix IndexOutOfBoundsException

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 11:53:56 2020 +0200| [46547ddf5f4fa74efc42d52d210623df7214a5f7] | committer: Nicolas Pomepuy

Fix IndexOutOfBoundsException

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

 .../tools/src/main/java/org/videolan/tools/livedata/LiveDataset.kt     | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/application/tools/src/main/java/org/videolan/tools/livedata/LiveDataset.kt b/application/tools/src/main/java/org/videolan/tools/livedata/LiveDataset.kt
index 350a3dd04..1d40b475a 100644
--- a/application/tools/src/main/java/org/videolan/tools/livedata/LiveDataset.kt
+++ b/application/tools/src/main/java/org/videolan/tools/livedata/LiveDataset.kt
@@ -82,7 +82,8 @@ class LiveDataset<T> : MutableLiveData<MutableList<T>>() {
     }
 
     fun move(item: T, newIndex: Int) {
-        move(internalList.indexOf(item), newIndex)
+        val from = internalList.indexOf(item)
+        if (from > 0) move(from, newIndex)
     }
 
     fun move(from: Int, to: Int) {



More information about the Android mailing list