[Android] Implement right-click support on media items
Geoffrey Métais
git at videolan.org
Tue Dec 12 11:14:09 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Dec 12 11:02:35 2017 +0100| [a4dcf76503fc3bbb90452d4e99e26b9cc7ec20f2] | committer: Geoffrey Métais
Implement right-click support on media items
> https://code.videolan.org/videolan/vlc-android/commit/a4dcf76503fc3bbb90452d4e99e26b9cc7ec20f2
---
.../videolan/vlc/gui/audio/AudioBrowserAdapter.java | 19 +++++++++----------
.../org/videolan/vlc/gui/audio/PlaylistAdapter.java | 12 +++++++++---
.../videolan/vlc/gui/browser/BaseBrowserAdapter.java | 7 +++++++
.../org/videolan/vlc/gui/video/VideoListAdapter.java | 8 ++++++++
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
index 2020bf286..144cdb075 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserAdapter.java
@@ -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
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
index 07483fac3..5c6a0e38b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/PlaylistAdapter.java
@@ -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);
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 e6d4197e9..b04bcfdb0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -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() {
diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 7c2c892bb..65f1a9c01 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -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) {
More information about the Android
mailing list