[Android] Fix reordering button always shown

Geoffrey Métais git at videolan.org
Tue Apr 2 16:59:58 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Apr  2 15:17:20 2019 +0200| [0574272b4a5171e052e2bdf66e616860ccb473c1] | committer: Geoffrey Métais

Fix reordering button always shown

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

 .../src/org/videolan/vlc/gui/PlaylistActivity.java   |  2 +-
 .../videolan/vlc/gui/audio/AudioBrowserAdapter.java  | 20 +++++---------------
 2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
index a60c0c0fc..78fb73825 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
@@ -129,7 +129,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
                 }
             }
         });
-        mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this, this, false, true);
+        mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this, this, mIsPlaylist);
         mItemTouchHelper = new ItemTouchHelper(new SwipeDragItemTouchHelperCallback(mAdapter));
         mItemTouchHelper.attachToRecyclerView(mBinding.songs);
 
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 1fbab8c94..e45cb25f1 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -53,7 +53,6 @@ import java.util.List;
 import androidx.annotation.NonNull;
 import androidx.annotation.Nullable;
 import androidx.core.view.MotionEventCompat;
-import androidx.databinding.ViewDataBinding;
 import androidx.fragment.app.Fragment;
 import androidx.paging.PagedList;
 import androidx.paging.PagedListAdapter;
@@ -69,21 +68,19 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
     private final IEventsHandler mIEventsHandler;
     private final IListEventsHandler mListEventsHandler;
     private MultiSelectHelper<MediaLibraryItem> multiSelectHelper;
-    private final int mType;
-    private final boolean mHasSections;
     private final BitmapDrawable mDefaultCover;
+    private final boolean mReorder;
     /**
      * Awful hack to workaround the {@link PagedListAdapter} not keeping track of notifyItemMoved operations
      */
     private static boolean preventNextAnim;
 
-    public AudioBrowserAdapter(int type, IEventsHandler eventsHandler, IListEventsHandler listEventsHandler, boolean sections, boolean canBeReordered) {
+    public AudioBrowserAdapter(int type, IEventsHandler eventsHandler, IListEventsHandler listEventsHandler, boolean canBeReordered) {
         super(DIFF_CALLBACK);
         multiSelectHelper = new MultiSelectHelper<>(this, Constants.UPDATE_SELECTION);
         mIEventsHandler = eventsHandler;
-        mType = type;
-        mHasSections = sections;
         mListEventsHandler = listEventsHandler;
+        mReorder = canBeReordered;
         Context ctx = null;
         if (eventsHandler instanceof Context) ctx = (Context) eventsHandler;
         else if (eventsHandler instanceof Fragment) ctx = ((Fragment)eventsHandler).getContext();
@@ -91,7 +88,7 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
     }
 
     public AudioBrowserAdapter(int type, IEventsHandler eventsHandler) {
-        this(type, eventsHandler, null, true, false);
+        this(type, eventsHandler, null, false);
     }
 
     @NonNull
@@ -110,7 +107,6 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
         final boolean isSelected = multiSelectHelper.isSelected(position);
         holder.setCoverlay(isSelected);
         holder.selectView(isSelected);
-        holder.setCanBeReordered(mListEventsHandler != null);
         holder.binding.executePendingBindings();
     }
 
@@ -128,7 +124,6 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
                     final boolean isSelected = multiSelectHelper.isSelected(position);
                     holder.setCoverlay(isSelected);
                     holder.selectView(isSelected);
-                    holder.setCanBeReordered(mListEventsHandler != null);
                 }
             }
         }
@@ -210,7 +205,6 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
     public class MediaItemViewHolder extends SelectorViewHolder<AudioBrowserItemBinding> implements View.OnFocusChangeListener {
         int coverlayResource = 0;
         public View.OnTouchListener onTouchListener;
-        private boolean canBeReordered;
 
         @TargetApi(Build.VERSION_CODES.M)
         MediaItemViewHolder(AudioBrowserItemBinding binding) {
@@ -281,12 +275,8 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
             return multiSelectHelper.isSelected(getLayoutPosition());
         }
 
-        public void setCanBeReordered(boolean canBeReordered) {
-            this.canBeReordered = canBeReordered;
-        }
-
         public boolean getCanBeReordered() {
-            return canBeReordered;
+            return mReorder;
         }
     }
 



More information about the Android mailing list