[Android] Spare 1 copy during updates

Geoffrey Métais git at videolan.org
Wed Dec 7 12:18:48 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Dec  7 09:53:42 2016 +0100| [b219f5e6e0bcf6afe59e6f7303147a7e8f43dc78] | committer: Geoffrey Métais

Spare 1 copy during updates

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

 vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java | 3 +--
 vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java     | 3 +--
 vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java    | 3 +--
 3 files changed, 3 insertions(+), 6 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 a140231..6abcbce 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -240,9 +240,8 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
         VLCApplication.runBackground(new Runnable() {
             @Override
             public void run() {
-                final MediaLibraryItem[] oldList = isEmpty() ? null : Arrays.copyOf(getAll(), getItemCount());
                 final MediaLibraryItem[] newList = hasSections() ? generateList(items) : items;
-                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(oldList, newList));
+                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(getAll(), newList));
                 mContext.runOnUiThread(new Runnable() {
                     @Override
                     public void run() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
index 94966b0..a845f8b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
@@ -127,8 +127,7 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
         VLCApplication.runBackground(new Runnable() {
             @Override
             public void run() {
-                final ArrayList<MediaWrapper> oldList = new ArrayList<>(mDataSet);
-                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(oldList, newList));
+                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mDataSet, newList));
                 mHandler.post(new Runnable() {
                     @Override
                     public void run() {
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 295753d..4b782e0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -510,13 +510,12 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
         VLCApplication.runBackground(new Runnable() {
             @Override
             public void run() {
-                final ArrayList<MediaWrapper> oldList = getAll();
                 final SortedList<MediaWrapper> newSortedList = new SortedList<>(MediaWrapper.class, mVideoComparator);
                 newSortedList.addAll(items);
                 final ArrayList<MediaWrapper> newList = new ArrayList<>(newSortedList.size());
                 for (int i = 0; i < newSortedList.size(); ++i)
                     newList.add(newSortedList.get(i));
-                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new VideoItemDiffCallback(oldList, newList));
+                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new VideoItemDiffCallback(getAll(), newList));
                 mHandler.post(new Runnable() {
                     @Override
                     public void run() {



More information about the Android mailing list