[Android] Fix context menu trigger on Android 2.x

Geoffrey Métais git at videolan.org
Wed Nov 25 19:04:07 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Nov 25 19:03:22 2015 +0100| [054ae3e7343cd8bfd8f375a94acc3d2e0276a4cc] | committer: Geoffrey Métais

Fix context menu trigger on Android 2.x

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=054ae3e7343cd8bfd8f375a94acc3d2e0276a4cc
---

 .../vlc/gui/browser/BaseBrowserAdapter.java        |    2 +-
 .../vlc/gui/browser/BaseBrowserFragment.java       |   20 ++------------------
 2 files changed, 3 insertions(+), 19 deletions(-)

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 c968c11..9516a00 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -306,7 +306,7 @@ public class BaseBrowserAdapter extends  RecyclerView.Adapter<RecyclerView.ViewH
         }
 
         public void onMoreClick(View v){
-            fragment.onPopupMenu(v,((Integer)v.getTag()).intValue());
+            fragment.openContextMenu(((Integer) v.getTag()).intValue());
         }
     }
 
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 3b54d70..8dcc1d7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserFragment.java
@@ -32,7 +32,6 @@ import android.support.design.widget.Snackbar;
 import android.support.v4.app.Fragment;
 import android.support.v4.app.FragmentTransaction;
 import android.support.v7.widget.LinearLayoutManager;
-import android.support.v7.widget.PopupMenu;
 import android.support.v7.widget.RecyclerView;
 import android.text.TextUtils;
 import android.util.SparseArray;
@@ -46,7 +45,6 @@ import android.view.ViewGroup;
 import android.widget.TextView;
 
 import org.videolan.libvlc.Media;
-import org.videolan.libvlc.util.AndroidUtil;
 import org.videolan.libvlc.util.MediaBrowser;
 import org.videolan.vlc.R;
 import org.videolan.vlc.VLCApplication;
@@ -414,22 +412,8 @@ public abstract class BaseBrowserFragment extends MediaBrowserFragment implement
     }
 
     @TargetApi(Build.VERSION_CODES.HONEYCOMB)
-    public void onPopupMenu(View anchor, final int position) {
-        if (!AndroidUtil.isHoneycombOrLater()) {
-            // Call the "classic" context menu
-            anchor.performLongClick();
-            return;
-        }
-        PopupMenu popupMenu = new PopupMenu(getActivity(), anchor);
-        setContextMenu(popupMenu.getMenuInflater(), popupMenu.getMenu(), position);
-
-        popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
-            @Override
-            public boolean onMenuItemClick(MenuItem item) {
-                return handleContextItemSelected(item, position);
-            }
-        });
-        popupMenu.show();
+    public void openContextMenu(final int position) {
+        mRecyclerView.openContextMenu(position);
     }
 
     protected boolean handleContextItemSelected(MenuItem item, int position) {



More information about the Android mailing list