[Android] Rename audio adapter section field

Geoffrey Métais git at videolan.org
Thu Feb 14 16:54:22 CET 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 14 16:53:50 2019 +0100| [be2c6c6316ecffeeeccd3585c9bbac97a4c251d9] | committer: Geoffrey Métais

Rename audio adapter section field

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

 .../src/org/videolan/vlc/gui/PlaylistActivity.java       |  2 +-
 .../org/videolan/vlc/gui/audio/AudioBrowserAdapter.java  | 16 +++++++---------
 .../src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java |  2 +-
 3 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
index 112d31ef1..0301105a5 100644
--- a/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/PlaylistActivity.java
@@ -118,7 +118,7 @@ public class PlaylistActivity extends AudioPlayerContainerActivity implements IE
                 }
             }
         });
-        mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this, tracksModel);
+        mAdapter = new AudioBrowserAdapter(MediaLibraryItem.TYPE_MEDIA, this, tracksModel, false);
 
         mBinding.songs.setLayoutManager(new LinearLayoutManager(this));
         mBinding.songs.setAdapter(mAdapter);
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 1d7a344f7..963a604d7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -64,22 +64,22 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
     private final IEventsHandler mIEventsHandler;
     private MultiSelectHelper<MediaLibraryItem> multiSelectHelper;
     private final int mType;
-    private int mSort;
+    private final boolean mHasSections;
     private final BitmapDrawable mDefaultCover;
     private final MLPagedModel mModel;
 
-    public AudioBrowserAdapter(int type, IEventsHandler eventsHandler, MLPagedModel model) {
+    public AudioBrowserAdapter(int type, IEventsHandler eventsHandler, MLPagedModel model, boolean sections) {
         super(DIFF_CALLBACK);
         multiSelectHelper = new MultiSelectHelper<>(this, Constants.UPDATE_SELECTION);
         mIEventsHandler = eventsHandler;
         mType = type;
         mDefaultCover = getIconDrawable();
-        mSort = model.getSort();
         mModel = model;
+        mHasSections = sections;
     }
 
-    void setSort(int sort) {
-        mSort = sort;
+    public AudioBrowserAdapter(int type, IEventsHandler eventsHandler, MLPagedModel model) {
+        this(type, eventsHandler, model, true);
     }
 
     @NonNull
@@ -94,9 +94,8 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
     public void onBindViewHolder(@NonNull MediaItemViewHolder holder, int position) {
         if (position >= getItemCount()) return;
         final MediaLibraryItem item = getItem(position);
-        if (item == null) return;
         holder.binding.setItem(item);
-        setHeader(holder, position);
+        if (mHasSections) setHeader(holder, position);
         final boolean isSelected = multiSelectHelper.isSelected(position);
         holder.setCoverlay(isSelected);
         holder.selectView(isSelected);
@@ -114,7 +113,7 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
                 holder.selectView(isSelected);
             } else if (payload instanceof Integer) {
                 if ((Integer) payload == UPDATE_PAYLOAD) {
-                    setHeader(holder, position);
+                    if (mHasSections) setHeader(holder, position);
                 } else if ((Integer) payload == Constants.UPDATE_SELECTION) {
                     final boolean isSelected = multiSelectHelper.isSelected(position);
                     holder.setCoverlay(isSelected);
@@ -125,7 +124,6 @@ public class AudioBrowserAdapter extends PagedListAdapter<MediaLibraryItem, Audi
     }
 
     private void setHeader(MediaItemViewHolder holder, int position) {
-        if (mSort == -1) return;
         holder.binding.setHeader(mModel.getHeaderForPostion(position));
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
index e13c3e57a..fd5f533d8 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/BaseAudioBrowser.java
@@ -231,7 +231,7 @@ public abstract class BaseAudioBrowser extends MediaBrowserFragment<MLPagedModel
 
     @Override
     protected void sortBy(int sort) {
-        if (ModelsHelperKt.canSortBy(getViewModel(), sort)) getCurrentAdapter().setSort(sort);
+        ModelsHelperKt.canSortBy(getViewModel(), sort);
         super.sortBy(sort);
     }
 



More information about the Android mailing list