[Android] Playlist items don't have stable IDs

Geoffrey Métais git at videolan.org
Fri Jan 18 18:23:48 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jan 18 18:19:50 2019 +0100| [bd0f53881fa68573ec67612d515fc620949e8f70] | committer: Geoffrey Métais

Playlist items don't have stable IDs

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

 .../src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java        | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
index ac4f22521..3eeb03de6 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -56,6 +56,7 @@ import androidx.paging.PagedListAdapter;
 import androidx.recyclerview.widget.DiffUtil;
 
 import static org.videolan.medialibrary.media.MediaLibraryItem.FLAG_SELECTED;
+import static org.videolan.medialibrary.media.MediaLibraryItem.TYPE_PLAYLIST;
 
 public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, AudioBrowserAdapter.ViewHolder> implements MultiSelectAdapter<MediaLibraryItem> {
 
@@ -75,7 +76,7 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
         mType = type;
         mDefaultCover = getIconDrawable();
         mSort = sort;
-        setHasStableIds(true);
+        setHasStableIds(type != TYPE_PLAYLIST);
     }
 
     void setSort(int sort) {
@@ -159,7 +160,9 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
 
     @Override
     public long getItemId(int position) {
-        return isPositionValid(position) ? getItem(position).getId() : -1;
+        if (!isPositionValid(position)) return -1;
+        final MediaLibraryItem item = getItem(position);
+        return item != null ? item.getId() : -1;
     }
 
     @Nullable



More information about the Android mailing list