[Android] Clear adapter on update to prevent crash

Geoffrey Métais git at videolan.org
Tue Nov 22 17:05:42 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Nov 22 17:03:33 2016 +0100| [3fd1442b047edde0985c62aeaa0d1ca6f1467dad] | committer: Geoffrey Métais

Clear adapter on update to prevent crash

This is a workaround, may be fixed with a future leanback release

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

 .../src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
index b9a1898..ab0957a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/SortedBrowserFragment.java
@@ -184,7 +184,8 @@ public abstract class SortedBrowserFragment extends BrowseFragment implements Br
         Activity activity = getActivity();
         if (activity == null)
             return;
-        mAdapter.clear();
+        mAdapter = new ArrayObjectAdapter(new ListRowPresenter());
+        setAdapter(mAdapter);
         ArrayObjectAdapter adapter;
         HeaderItem header;
         for (ListItem item : mMediaItemMap.values()){
@@ -200,7 +201,7 @@ public abstract class SortedBrowserFragment extends BrowseFragment implements Br
         addMedia(new MediaWrapper(media));
     }
 
-    protected void addMedia(MediaWrapper mw){
+    protected void addMedia(MediaWrapper mw) {
         int type = mw.getType();
         if (type != MediaWrapper.TYPE_AUDIO && type != MediaWrapper.TYPE_VIDEO && type != MediaWrapper.TYPE_DIR)
             return;



More information about the Android mailing list