[Android] Use correct list in video DiffUtil callbacks

Geoffrey Métais git at videolan.org
Fri Feb 16 16:26:54 CET 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 16 16:26:16 2018 +0100| [e6d7aa75022e7965833d0f9f12941da252e06fd0] | committer: Geoffrey Métais

Use correct list in video DiffUtil callbacks

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

 vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java | 6 +++---
 vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java | 7 ++-----
 2 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 60a89c84b..baeb3ac4c 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -388,14 +388,14 @@ public class VideoListAdapter extends SortableAdapter<MediaWrapper, VideoListAda
 
         @Override
         public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
-            final MediaWrapper oldItem = getDataset().get(oldItemPosition);
+            final MediaWrapper oldItem = oldList.get(oldItemPosition);
             final MediaWrapper newItem = newList.get(newItemPosition);
             return oldItem == newItem || (oldItem.getType() == newItem.getType() && oldItem.equals(newItem));
         }
 
         @Override
         public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
-            final MediaWrapper oldItem = getDataset().get(oldItemPosition);
+            final MediaWrapper oldItem = oldList.get(oldItemPosition);
             final MediaWrapper newItem = newList.get(newItemPosition);
             return oldItem == newItem || (oldItem.getTime() == newItem.getTime()
                     && TextUtils.equals(oldItem.getArtworkMrl(), newItem.getArtworkMrl())
@@ -405,7 +405,7 @@ public class VideoListAdapter extends SortableAdapter<MediaWrapper, VideoListAda
         @Nullable
         @Override
         public Object getChangePayload(int oldItemPosition, int newItemPosition) {
-            final MediaWrapper oldItem = getDataset().get(oldItemPosition);
+            final MediaWrapper oldItem = oldList.get(oldItemPosition);
             final MediaWrapper newItem = newList.get(newItemPosition);
             if (oldItem.getTime() != newItem.getTime())
                 return UPDATE_TIME;
diff --git a/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java b/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java
index 8b183c126..bc9cce9a3 100644
--- a/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java
+++ b/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java
@@ -1,18 +1,15 @@
 package org.videolan.vlc.util;
 
-import org.jetbrains.annotations.NotNull;
 import org.videolan.medialibrary.media.MediaLibraryItem;
 import org.videolan.vlc.gui.DiffUtilAdapter;
 
-import java.util.List;
-
 
 public class MediaItemDiffCallback< T extends MediaLibraryItem> extends DiffUtilAdapter.DiffCallback<T> {
     private static final String TAG = "MediaItemDiffCallback";
 
     @Override
     public int getOldListSize() {
-        return getOldList().size();
+        return oldList.size();
     }
 
     @Override
@@ -22,7 +19,7 @@ public class MediaItemDiffCallback< T extends MediaLibraryItem> extends DiffUtil
 
     @Override
     public boolean areItemsTheSame(int oldItemPosition, int newItemPosition) {
-        final MediaLibraryItem oldItem = getOldList().get(oldItemPosition);
+        final MediaLibraryItem oldItem = oldList.get(oldItemPosition);
         final MediaLibraryItem newItem = newList.get(newItemPosition);
         return oldItem == newItem || ((oldItem == null ) == (newItem == null) && oldItem.equals(newItem));
     }



More information about the Android mailing list