[Android] Safer videos grid refresh

Geoffrey Métais git at videolan.org
Fri Jun 10 11:07:41 CEST 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Jun 10 11:06:57 2016 +0200| [e3b0919d1873866d2e5289cd00483458041c4012] | committer: Geoffrey Métais

Safer videos grid refresh

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

 .../src/org/videolan/vlc/gui/video/VideoGridFragment.java  | 14 ++++++++++----
 .../src/org/videolan/vlc/gui/video/VideoListAdapter.java   |  1 -
 2 files changed, 10 insertions(+), 5 deletions(-)

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 d86590d..0c7265d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoGridFragment.java
@@ -420,10 +420,16 @@ public class VideoGridFragment extends MediaBrowserFragment implements ISortable
                         }
                     }
 
-                    mVideoAdapter.addAll(displayList);
-                    mVideoAdapter.sort();
-                    if (mReadyToDisplay)
-                        display();
+                    mGridView.post(new Runnable() {
+                        @Override
+                        public void run() {
+                            mVideoAdapter.clear();
+                            mVideoAdapter.addAll(displayList);
+                            mVideoAdapter.sort();
+                            if (mReadyToDisplay)
+                                display();
+                        }
+                    });
                     if (mThumbnailer != null && !jobsList.isEmpty()) {
                         for (MediaWrapper item : jobsList)
                             mThumbnailer.addJob(item);
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 7049309..857da46 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -233,7 +233,6 @@ public class VideoListAdapter extends RecyclerView.Adapter<VideoListAdapter.View
     }
 
     public void addAll(Collection<MediaWrapper> items) {
-        mVideos.clear();
         mVideos.addAll(items);
         MediaWrapper mw;
         Object[] array = items.toArray();



More information about the Android mailing list