[Android] Copy former list to get proper diff

Geoffrey Métais git at videolan.org
Tue Dec 6 14:32:27 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Dec  6 13:37:21 2016 +0100| [5a447a397fb7f0e9a565d49beed49dc6e8ed4b41] | committer: Geoffrey Métais

Copy former list to get proper diff

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

 vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java | 3 +--
 1 file changed, 1 insertion(+), 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 d6e1fc3..a70f6c2 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -229,8 +229,7 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
     }
 
     void dispatchUpdate(final MediaLibraryItem[] newList) {
-        final MediaLibraryItem[] oldList = getAll();
-        clear();
+        final MediaLibraryItem[] oldList = isEmpty() ? null : Arrays.copyOf(getAll(), getItemCount());
         addAll(newList);
         final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(oldList, getAll()));
         mContext.runOnUiThread(new Runnable() {



More information about the Android mailing list