[Android] Enable move detect only for changing RV sorting

Geoffrey Métais git at videolan.org
Fri Feb 3 21:22:21 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb  3 21:22:03 2017 +0100| [87a7c9c5f43e1832fa322587afa86e7162190980] | committer: Geoffrey Métais

Enable move detect only for changing RV sorting

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

 .../videolan/vlc/gui/audio/AudioBrowserAdapter.java   |  2 +-
 .../org/videolan/vlc/gui/audio/PlaylistAdapter.java   |  2 +-
 .../videolan/vlc/gui/browser/BaseBrowserAdapter.java  |  2 +-
 .../org/videolan/vlc/gui/video/VideoGridFragment.java |  2 +-
 .../org/videolan/vlc/gui/video/VideoListAdapter.java  | 19 +++++++------------
 5 files changed, 11 insertions(+), 16 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 5091381..90c0826 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -277,7 +277,7 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
             @Override
             public void run() {
                 final MediaLibraryItem[] newList = mOriginalDataSet == null && hasSections() ? generateList(items) : items;
-                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mDataList, newList), AndroidUtil.isICSOrLater());
+                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mDataList, newList), false);
                 addAll(newList, false);
                 result.dispatchUpdatesTo(AudioBrowserAdapter.this);
                 mIEventsHandler.onUpdateFinished(AudioBrowserAdapter.this);
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 a688f87..8cebbfa 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
@@ -124,7 +124,7 @@ public class PlaylistAdapter extends RecyclerView.Adapter<PlaylistAdapter.ViewHo
 
     @MainThread
     public void dispatchUpdate(final List<MediaWrapper> newList) {
-        final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mDataSet, newList), AndroidUtil.isICSOrLater());
+        final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mDataSet, newList), false);
         mDataSet.clear();
         addAll(newList);
         result.dispatchUpdatesTo(this);
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index fe6e46a..5cbc7f9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -363,7 +363,7 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<BaseBrowserAdapter.
         VLCApplication.runOnMainThread(new Runnable() {
             @Override
             public void run() {
-                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mMediaList, items), AndroidUtil.isICSOrLater());
+                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mMediaList, items), false);
                 mMediaList = items;
                 result.dispatchUpdatesTo(BaseBrowserAdapter.this);
                 fragment.onUpdateFinished(null);
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
index e320bc3..4ebad9b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -400,7 +400,7 @@ public class VideoGridFragment extends MediaBrowserFragment implements MediaUpda
                 }
                 final SortedList<MediaWrapper> newSortedList = new SortedList<>(MediaWrapper.class, mVideoAdapter.getComparator());
                 newSortedList.addAll(displayList);
-                mVideoAdapter.dispatchUpdate(newSortedList);
+                mVideoAdapter.dispatchUpdate(newSortedList, false);
                 mHandler.sendEmptyMessage(UNSET_REFRESHING);
             }
         });
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 306a43e..79b4f68 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -140,11 +140,6 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
         holder.binding.setVariable(BR.cover, AsyncImageLoader.DEFAULT_COVER_VIDEO_DRAWABLE);
     }
 
-    public void sort() {
-        if (!isEmpty())
-            dispatchUpdate(getAll());
-    }
-
     public boolean isEmpty()
     {
         return mVideos.size() == 0;
@@ -410,7 +405,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
                     mSortDirection = 1;
                     break;
             }
-            dispatchUpdate(getAll());
+            dispatchUpdate(getAll(), true);
 
             SharedPreferences.Editor editor = mSettings.edit();
             editor.putInt(KEY_SORT_BY, mSortBy);
@@ -472,7 +467,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
     @MainThread
     void restoreList() {
         if (mOriginalData != null) {
-            dispatchUpdate(new ArrayList<>(mOriginalData));
+            dispatchUpdate(new ArrayList<>(mOriginalData), false);
             mOriginalData = null;
         }
     }
@@ -492,7 +487,7 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
         @Override
         protected void publishResults(CharSequence charSequence, FilterResults filterResults) {
             //noinspection unchecked
-            dispatchUpdate((ArrayList<MediaWrapper>) filterResults.values);
+            dispatchUpdate((ArrayList<MediaWrapper>) filterResults.values, false);
         }
     }
 
@@ -505,17 +500,17 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
         view.setLayoutParams(layoutParams);
     }
 
-    void dispatchUpdate(final ArrayList<MediaWrapper> items) {
+    void dispatchUpdate(final ArrayList<MediaWrapper> items, boolean detectMoves) {
         final SortedList<MediaWrapper> newSortedList = new SortedList<>(MediaWrapper.class, mVideoComparator);
         newSortedList.addAll(items);
-        dispatchUpdate(newSortedList);
+        dispatchUpdate(newSortedList, detectMoves);
     }
 
-    void dispatchUpdate(final SortedList<MediaWrapper> items) {
+    void dispatchUpdate(final SortedList<MediaWrapper> items, final boolean detectMoves) {
         VLCApplication.runOnMainThread(new Runnable() {
             @Override
             public void run() {
-                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new VideoItemDiffCallback(mVideos, items), AndroidUtil.isICSOrLater());
+                final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new VideoItemDiffCallback(mVideos, items), detectMoves);
                 mVideos = items;
                 result.dispatchUpdatesTo(VideoListAdapter.this);
                 mEventsHandler.onUpdateFinished(null);



More information about the Android mailing list