[Android] Audio browser: open the AudioAlbumsSongsFragment when clicking on an artist

Adrien Maglo git at videolan.org
Tue Nov 19 16:03:34 CET 2013


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Tue Nov 19 16:03:23 2013 +0100| [e8e1a31b7db1f188c5f4e7bc4fb5d9849801e7d3] | committer: Adrien Maglo

Audio browser: open the AudioAlbumsSongsFragment when clicking on an artist

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

 .../org/videolan/vlc/gui/audio/AudioBrowserFragment.java    |   11 +++++++++++
 .../org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java |    8 ++++++++
 2 files changed, 19 insertions(+)

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 d7b2922..4083883 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -20,6 +20,7 @@
 
 package org.videolan.vlc.gui.audio;
 
+import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.List;
@@ -146,6 +147,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
         artistList.setOnGroupClickListener(playlistListener);
         albumList.setOnGroupClickListener(playlistListener);
         genreList.setOnGroupClickListener(playlistListener);
+        artistList2.setOnItemClickListener(browserListListener);
 
         artistList.setOnChildClickListener(playlistChildListener);
         albumList.setOnChildClickListener(playlistChildListener);
@@ -249,6 +251,15 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
         }
     };
 
+    OnItemClickListener browserListListener = new OnItemClickListener() {
+        @Override
+        public void onItemClick(AdapterView<?> av, View v, int p, long id) {
+            ArrayList<Media> mediaList = mArtistsAdapter2.getMedia(p);
+            AudioAlbumsSongsFragment frag = new AudioAlbumsSongsFragment(mediaList);
+            MainActivity.ShowFragment(getActivity(), "albumsSongsFromArtist", frag);
+        }
+    };
+
     @Override
     public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
         MenuInflater inflater = getActivity().getMenuInflater();
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index d8df432..607b99e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -245,4 +245,12 @@ public class AudioBrowserListAdapter implements ListAdapter {
     public boolean isEnabled(int position) {
         return true;
     }
+
+    public ArrayList<Media> getMedia(int position) {
+        // Return all the media of a list item list.
+        ArrayList<Media> mediaList = new ArrayList<Media>();
+        if (!mItems.get(position).mIsSeparator)
+            mediaList.addAll(mItems.get(position).mMediaList);
+        return mediaList;
+    }
 }



More information about the Android mailing list