Commit a4dcf765 authored by Geoffrey Métais's avatar Geoffrey Métais

Implement right-click support on media items

parent 0029645e
......@@ -35,6 +35,7 @@ import android.view.ViewGroup;
import android.widget.Filter;
import android.widget.Filterable;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.medialibrary.media.DummyItem;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
......@@ -425,8 +426,14 @@ public class AudioBrowserAdapter extends SortableAdapter<MediaLibraryItem, Audio
MediaItemViewHolder(AudioBrowserItemBinding binding) {
super(binding);
binding.setHolder(this);
if (mDefaultCover != null)
binding.setCover(mDefaultCover);
if (mDefaultCover != null) binding.setCover(mDefaultCover);
if (AndroidUtil.isMarshMallowOrLater) itemView.setOnContextClickListener(new View.OnContextClickListener() {
@Override
public boolean onContextClick(View v) {
onMoreClick(v);
return true;
}
});
}
public void onClick(View v) {
......@@ -464,14 +471,6 @@ public class AudioBrowserAdapter extends SortableAdapter<MediaLibraryItem, Audio
protected boolean isSelected() {
return getItem(getLayoutPosition()).hasStateFlags(FLAG_SELECTED);
}
// private void setViewBackground(boolean focused, boolean selected) {
// int selectionColor = selected || focused ? UiTools.ITEM_SELECTION_ON : 0;
// if (selectionColor != this.selectionColor) {
// itemView.setBackgroundColor(selectionColor);
// this.selectionColor = selectionColor;
// }
// }
}
@Override
......
......@@ -28,7 +28,6 @@ import android.databinding.DataBindingUtil;
import android.os.Message;
import android.support.annotation.MainThread;
import android.support.v4.app.Fragment;
import android.support.v7.util.DiffUtil;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
......@@ -37,6 +36,7 @@ import android.widget.Filter;
import android.widget.Filterable;
import android.widget.Toast;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.medialibrary.media.MediaWrapper;
import org.videolan.vlc.PlaybackService;
import org.videolan.vlc.R;
......@@ -46,7 +46,6 @@ import org.videolan.vlc.gui.DiffUtilAdapter;
import org.videolan.vlc.gui.helpers.UiTools;
import org.videolan.vlc.interfaces.SwipeDragHelperAdapter;
import org.videolan.vlc.media.MediaUtils;
import org.videolan.vlc.util.MediaItemDiffCallback;
import org.videolan.vlc.util.WeakHandler;
import java.util.ArrayList;
......@@ -172,13 +171,20 @@ public class PlaylistAdapter extends DiffUtilAdapter<MediaWrapper, PlaylistAdapt
mService = service;
}
public class ViewHolder extends RecyclerView.ViewHolder{
public class ViewHolder extends RecyclerView.ViewHolder {
PlaylistItemBinding binding;
public ViewHolder(View v) {
super(v);
binding = DataBindingUtil.bind(v);
binding.setHolder(this);
if (AndroidUtil.isMarshMallowOrLater) itemView.setOnContextClickListener(new View.OnContextClickListener() {
@Override
public boolean onContextClick(View v) {
onMoreClick(v);
return true;
}
});
}
public void onClick(View v, MediaWrapper media){
int position = getMediaPosition(media);
......
......@@ -168,6 +168,13 @@ public class BaseBrowserAdapter extends SortableAdapter<MediaLibraryItem, BaseBr
return true;
}
});
if (AndroidUtil.isMarshMallowOrLater) itemView.setOnContextClickListener(new View.OnContextClickListener() {
@Override
public boolean onContextClick(View v) {
onMoreClick(v);
return true;
}
});
}
void setContextMenuListener() {
......
......@@ -37,6 +37,7 @@ import android.widget.Filterable;
import android.widget.ImageView;
import android.widget.TextView;
import org.videolan.libvlc.util.AndroidUtil;
import org.videolan.medialibrary.Tools;
import org.videolan.medialibrary.media.MediaLibraryItem;
import org.videolan.medialibrary.media.MediaWrapper;
......@@ -304,6 +305,13 @@ public class VideoListAdapter extends SortableAdapter<MediaWrapper, VideoListAda
thumbView = itemView.findViewById(R.id.ml_item_thumbnail);
binding.setVariable(BR.holder, this);
binding.setVariable(BR.cover, AsyncImageLoader.DEFAULT_COVER_VIDEO_DRAWABLE);
if (AndroidUtil.isMarshMallowOrLater) itemView.setOnContextClickListener(new View.OnContextClickListener() {
@Override
public boolean onContextClick(View v) {
onMoreClick(v);
return true;
}
});
}
public void onClick(View v) {
......
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