[Android] Handle items removed by MediaBrowser
Geoffrey Métais
git at videolan.org
Thu Feb 11 17:07:10 CET 2016
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 11 17:06:30 2016 +0100| [90133dcd001766c5e0fd617ba6da855b861a5926] | committer: Geoffrey Métais
Handle items removed by MediaBrowser
> https://code.videolan.org/videolan/vlc-android/commit/90133dcd001766c5e0fd617ba6da855b861a5926
---
.../org/videolan/vlc/gui/browser/BaseBrowserAdapter.java | 16 ++++++++++++++++
.../videolan/vlc/gui/browser/BaseBrowserFragment.java | 2 +-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index 5b3ee62..480db4e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -25,6 +25,7 @@ package org.videolan.vlc.gui.browser;
import android.databinding.DataBindingUtil;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -286,6 +287,21 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
}
}
+ public void removeItem(String path, boolean notify){
+ int position = -1;
+ for (int i = 0; i< getItemCount(); ++i) {
+ Object item = mMediaList.get(i);
+ if (item instanceof MediaWrapper && TextUtils.equals(path, ((MediaWrapper) item).getUri().toString()))
+ position = i;
+ }
+ if (position == -1)
+ return;
+ mMediaList.remove(position);
+ if (notify) {
+ notifyItemRemoved(position);
+ }
+ }
+
public Object getItem(int position){
return mMediaList.get(position);
}
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
index 66b0d08..fd4a98d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -230,7 +230,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
@Override
public void onMediaRemoved(int index, Media media) {
- mAdapter.removeItem(index, mReadyToDisplay);
+ mAdapter.removeItem(media.getUri().toString(), mReadyToDisplay);
}
@Override
More information about the Android
mailing list