[Android] Fastcroll: Fix getSectionforPosition range check

Geoffrey Métais git at videolan.org
Mon Feb 18 15:53:58 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Feb 18 12:04:36 2019 +0100| [5986ca788e7d63be683aac285cf18a9516e4d26d] | committer: Geoffrey Métais

Fastcroll: Fix getSectionforPosition range check

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

 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 e3bdce712..af3ac0070 100644
--- a/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
+++ b/vlc-android/src/org/videolan/vlc/viewmodels/paged/MLPagedModel.kt
@@ -119,7 +119,7 @@ abstract class MLPagedModel<T : MediaLibraryItem>(context: Context) : SortableMo
 
     @MainThread
     fun getSectionforPosition(position: Int): String {
-        for (pos in 0 until headers.size()) if (position <= headers.keyAt(pos)) return headers.valueAt(pos)
+        for (pos in headers.size()-1 downTo 0) if (position >= headers.keyAt(pos)) return headers.valueAt(pos)
         return ""
     }
 



More information about the Android mailing list