[Android] Fix playlist load via context menu

Geoffrey Métais git at videolan.org
Mon May 4 13:55:48 CEST 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon May  4 10:40:29 2015 +0200| [2d14b8a4a4b70fe752351ad6b9d3b9f52ffffb63] | committer: Geoffrey Métais

Fix playlist load via context menu

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

 .../vlc/gui/audio/AudioBrowserFragment.java        |   31 +++++++++++---------
 1 file changed, 17 insertions(+), 14 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
index 5b84722..27d291a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -362,17 +362,21 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
     OnItemClickListener playlistListener = new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> av, View v, int p, long id) {
-            ArrayList<MediaWrapper> mediaList = mPlaylistAdapter.getItem(p).mMediaList;
-            if (mediaList.size() == 1) {
-                String mediaLocation = mediaList.get(0).getLocation();
-                mAudioController.load(mediaLocation);
-            } else {
-                ArrayList<String> mediaLocations = mPlaylistAdapter.getLocations(p);
-                mAudioController.load(mediaLocations, 0);
-            }
+            loadPlaylist(p);
         }
     };
 
+    private void loadPlaylist(int position) {
+        ArrayList<MediaWrapper> mediaList = mPlaylistAdapter.getItem(position).mMediaList;
+        if (mediaList.size() == 1) {
+            String mediaLocation = mediaList.get(0).getLocation();
+            mAudioController.load(mediaLocation);
+        } else {
+            ArrayList<String> mediaLocations = mPlaylistAdapter.getLocations(position);
+            mAudioController.load(mediaLocations, 0);
+        }
+    }
+
     @Override
     public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
         MenuInflater inflater = getActivity().getMenuInflater();
@@ -471,8 +475,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
                 return false;
             medias = new ArrayList<String>();
             startPosition = mSongsAdapter.getListWithPosition(medias, groupPosition);
-        }
-        else {
+        } else {
             startPosition = 0;
             AudioBrowserListAdapter adapter = null;
             switch (mode){
@@ -495,10 +498,11 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
                             mMediaBrowser = new MediaBrowser(VLCInstance.get(), this);
                         mMediaBrowser.browse(mPlaylistAdapter.getMedia(groupPosition).get(0).getLocation());
                         return true;
-                    }
+                    } else
+                        adapter = mPlaylistAdapter;
                     break;
                 default:
-                    return true;
+                    return false;
             }
             if (groupPosition >= adapter.getCount())
                 return false;
@@ -509,8 +513,7 @@ public class AudioBrowserFragment extends MediaBrowserFragment implements SwipeR
             mAudioController.append(medias);
         else
             mAudioController.load(medias, startPosition);
-
-        return super.onContextItemSelected(item);
+        return true;
     }
 
     public void onFabPlayAllClick(View view) {



More information about the Android mailing list