[Android] Fix audio refresh

Geoffrey Métais git at videolan.org
Sat Dec 3 17:39:33 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Sat Dec  3 17:39:25 2016 +0100| [cbd4c69b73766f7bae5c11e774813b12b38b3e80] | committer: Geoffrey Métais

Fix audio refresh

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

 .../videolan/vlc/gui/audio/AudioBrowserAdapter.java    | 18 ++++++------------
 .../org/videolan/vlc/util/MediaItemDiffCallback.java   |  2 +-
 2 files changed, 7 insertions(+), 13 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 8fb1ae8..d6e1fc3 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -161,6 +161,8 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
             boolean isLetter;
             String currentLetter = null;
             for (MediaLibraryItem item : items) {
+                if (item.getItemType() == MediaLibraryItem.TYPE_DUMMY)
+                    continue;
                 String title = item.getTitle();
                 if (TextUtils.isEmpty(title))
                     continue;
@@ -222,23 +224,15 @@ public class AudioBrowserAdapter extends RecyclerView.Adapter<AudioBrowserAdapte
     }
 
     public void restoreList() {
-        if (mOriginalDataSet != null) {
-            final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(mDataList, mOriginalDataSet));
-            mContext.runOnUiThread(new Runnable() {
-                @Override
-                public void run() {
-                    result.dispatchUpdatesTo(AudioBrowserAdapter.this);
-                }
-            });
-            mDataList = mOriginalDataSet;
-            mOriginalDataSet = null;
-        }
+        if (mOriginalDataSet != null)
+            dispatchUpdate(mOriginalDataSet);
     }
 
     void dispatchUpdate(final MediaLibraryItem[] newList) {
         final MediaLibraryItem[] oldList = getAll();
+        clear();
         addAll(newList);
-        final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(oldList, newList));
+        final DiffUtil.DiffResult result = DiffUtil.calculateDiff(new MediaItemDiffCallback(oldList, getAll()));
         mContext.runOnUiThread(new Runnable() {
             @Override
             public void run() {
diff --git a/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java b/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java
index df682c7..6491261 100644
--- a/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java
+++ b/vlc-android/src/org/videolan/vlc/util/MediaItemDiffCallback.java
@@ -38,6 +38,6 @@ public class MediaItemDiffCallback extends DiffUtil.Callback {
 
     @Override
     public boolean areContentsTheSame(int oldItemPosition, int newItemPosition) {
-        return false;
+        return true;
     }
 }



More information about the Android mailing list