[Android] Audio player: fix the playlist item long click

Adrien Maglo git at videolan.org
Mon Jan 27 14:16:10 CET 2014


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Jan 27 14:16:02 2014 +0100| [abc0ca53fa1b6a8d36fcbbce595964d7dc4c60f2] | committer: Adrien Maglo

Audio player: fix the playlist item long click

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

 .../src/org/videolan/vlc/gui/audio/AudioListAdapter.java     |    8 ++++++++
 .../src/org/videolan/vlc/gui/audio/AudioPlaylistView.java    |   10 ++++++++++
 vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java |    8 ++++++++
 3 files changed, 26 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
index 1c170bf..135b9bf 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListAdapter.java
@@ -33,6 +33,7 @@ import android.view.LayoutInflater;
 import android.view.MotionEvent;
 import android.view.View;
 import android.view.View.OnClickListener;
+import android.view.View.OnLongClickListener;
 import android.view.View.OnTouchListener;
 import android.view.ViewGroup;
 import android.widget.ArrayAdapter;
@@ -137,6 +138,13 @@ public class AudioListAdapter extends ArrayAdapter<Media> {
                 playlistView.performItemClick(itemView, pos, 0);
             }
         });
+        holder.layoutItem.setOnLongClickListener(new OnLongClickListener() {
+            @Override
+            public boolean onLongClick(View v) {
+                playlistView.performItemLongClick(itemView, pos, 0);
+                return true;
+            }
+        });
 
         return v;
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
index e730647..e306ee0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioPlaylistView.java
@@ -43,6 +43,7 @@ public class AudioPlaylistView extends ListView {
 
     private OnItemDraggedListener mOnItemDraggedListener;
     private OnItemRemovedListener mOnItemRemovedListener;
+    private OnItemLongClickListener mOnItemLongClickListener;
 
     public AudioPlaylistView(Context context, AttributeSet attrs) {
         super(context, attrs);
@@ -219,4 +220,13 @@ public class AudioPlaylistView extends ListView {
         if (mOnItemRemovedListener != null)
             mOnItemRemovedListener.onItemRemoved(position);
     }
+
+    public void performItemLongClick(View view, int position, long id) {
+        if (mOnItemLongClickListener != null)
+            mOnItemLongClickListener.onItemLongClick(this, view, position, id);
+    }
+
+    public void setOnItemLongClickListener(OnItemLongClickListener l) {
+        mOnItemLongClickListener = l;
+    }
 }
diff --git a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
index 6d087c3..be61578 100644
--- a/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
+++ b/vlc-android/src/org/videolan/vlc/widget/AudioMiniPlayer.java
@@ -210,6 +210,14 @@ public class AudioMiniPlayer extends Fragment implements IAudioPlayer {
                 mAudioController.load(mSongsListAdapter.getLocations(), p);
             }
         });
+        mSongsList.setOnItemLongClickListener(new OnItemLongClickListener() {
+            @Override
+            public boolean onItemLongClick(AdapterView<?> parent, View view,
+                    int position, long id) {
+                getActivity().openContextMenu(view);
+                return true;
+            }
+        });
         mSongsList.setOnItemDraggedListener(new AudioPlaylistView.OnItemDraggedListener() {
             @Override
             public void OnItemDradded(int positionStart, int positionEnd) {



More information about the Android mailing list