[Android] TV: Handle onMediaRemove for servers

Geoffrey Métais git at videolan.org
Fri Feb 12 15:33:08 CET 2016


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 12 15:32:30 2016 +0100| [d7c465df65dd2a92eacce82703f39fa6dc2f7154] | committer: Geoffrey Métais

TV: Handle onMediaRemove for servers

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

 .../videolan/vlc/gui/tv/browser/BrowserGridFragment.java  | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
index 63c67f2..a93778a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/tv/browser/BrowserGridFragment.java
@@ -34,6 +34,7 @@ import android.support.v17.leanback.widget.OnItemViewSelectedListener;
 import android.support.v17.leanback.widget.Presenter;
 import android.support.v17.leanback.widget.Row;
 import android.support.v17.leanback.widget.RowPresenter;
+import android.text.TextUtils;
 
 import org.videolan.libvlc.Media;
 import org.videolan.libvlc.util.MediaBrowser;
@@ -109,7 +110,19 @@ public class BrowserGridFragment extends GridFragment implements MediaBrowser.Ev
     }
 
     @Override
-    public void onMediaRemoved(int index, Media media) {}
+    public void onMediaRemoved(int index, Media media) {
+        int position = -1;
+        String uri = media.getUri().toString();
+        for (int i = 0; i < mMediaList.size(); ++i) {
+            if (TextUtils.equals(mMediaList.get(i).getUri().toString(), uri)) {
+                position = i;
+                break;
+            }
+        }
+        if (position == -1)
+            return;
+        mAdapter.removeItems(position, 1);
+    }
 
     @Override
     public void onBrowseEnd() {



More information about the Android mailing list