Commit 90133dcd authored by Geoffrey Métais's avatar Geoffrey Métais

Handle items removed by MediaBrowser

parent a07dd907
...@@ -25,6 +25,7 @@ package org.videolan.vlc.gui.browser; ...@@ -25,6 +25,7 @@ package org.videolan.vlc.gui.browser;
import android.databinding.DataBindingUtil; import android.databinding.DataBindingUtil;
import android.net.Uri; import android.net.Uri;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
...@@ -286,6 +287,21 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH ...@@ -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){ public Object getItem(int position){
return mMediaList.get(position); return mMediaList.get(position);
} }
......
...@@ -230,7 +230,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement ...@@ -230,7 +230,7 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
@Override @Override
public void onMediaRemoved(int index, Media media) { public void onMediaRemoved(int index, Media media) {
mAdapter.removeItem(index, mReadyToDisplay); mAdapter.removeItem(media.getUri().toString(), mReadyToDisplay);
} }
@Override @Override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment