[Android] Audio browser: show the playlist when clicking on an album or a song and start playing the first media

Adrien Maglo git at videolan.org
Tue Nov 26 13:54:00 CET 2013


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Tue Nov 26 13:53:50 2013 +0100| [d8cc82da927f724b94cface5d3e199c275111a5b] | committer: Adrien Maglo

Audio browser: show the playlist when clicking on an album or a song and start playing the first media

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

 .../vlc/gui/audio/AudioAlbumsSongsFragment.java     |   17 ++++++-----------
 .../vlc/gui/audio/AudioBrowserFragment.java         |   17 ++++++-----------
 .../vlc/gui/audio/AudioBrowserListAdapter.java      |    6 +++---
 .../videolan/vlc/gui/audio/AudioListFragment.java   |   19 ++++---------------
 4 files changed, 19 insertions(+), 40 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
index 6509967..01c8806 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioAlbumsSongsFragment.java
@@ -168,15 +168,9 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
     OnItemClickListener albumsListener = new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> av, View v, int p, long id) {
-            String name = mAlbumsAdapter.getMedia(p).get(0).getAlbum();
-
+            ArrayList<String> mediaLocation = mAlbumsAdapter.getLocations(p);
+            mAudioController.load(mediaLocation, 0);
             AudioListFragment audioList = new AudioListFragment();
-            Bundle b = new Bundle();
-            b.putString(AudioListFragment.EXTRA_NAME, name);
-            b.putString(AudioListFragment.EXTRA_NAME2, null);
-            b.putInt(AudioListFragment.EXTRA_MODE, AudioBrowserFragment.MODE_ALBUM);
-            audioList.setArguments(b);
-
             MainActivity.ShowFragment(getActivity(), "tracks", audioList);
         }
     };
@@ -184,9 +178,10 @@ public class AudioAlbumsSongsFragment extends SherlockFragment {
     OnItemClickListener songsListener = new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> av, View v, int p, long id) {
-            ArrayList<String> mediaLocations = mSongsAdapter.getLocations(p);
-            mAudioController.load(mediaLocations, p);
-            AudioPlayerFragment.start(getActivity());
+            ArrayList<String> mediaLocation = mSongsAdapter.getLocations(p);
+            mAudioController.load(mediaLocation, 0);
+            AudioListFragment audioList = new AudioListFragment();
+            MainActivity.ShowFragment(getActivity(), "tracks", audioList);
         }
     };
 }
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 306fe1b..67b93bd 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -162,9 +162,10 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
     OnItemClickListener songListener = new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> av, View v, int p, long id) {
-            ArrayList<String> mediaLocations = mSongsAdapter.getLocations(p);
-            mAudioController.load(mediaLocations, p);
-            AudioPlayerFragment.start(getActivity());
+            ArrayList<String> mediaLocation = mSongsAdapter.getLocations(p);
+            mAudioController.load(mediaLocation, 0);
+            AudioListFragment audioList = new AudioListFragment();
+            MainActivity.ShowFragment(getActivity(), "tracks", audioList);
         }
     };
 
@@ -180,15 +181,9 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
     OnItemClickListener albumListListener = new OnItemClickListener() {
         @Override
         public void onItemClick(AdapterView<?> av, View v, int p, long id) {
-            String name = mAlbumsAdapter.getMedia(p).get(0).getAlbum();
-
+            ArrayList<String> mediaLocation = mAlbumsAdapter.getLocations(p);
+            mAudioController.load(mediaLocation, 0);
             AudioListFragment audioList = new AudioListFragment();
-            Bundle b = new Bundle();
-            b.putString(AudioListFragment.EXTRA_NAME, name);
-            b.putString(AudioListFragment.EXTRA_NAME2, null);
-            b.putInt(AudioListFragment.EXTRA_MODE, AudioBrowserFragment.MODE_ALBUM);
-            audioList.setArguments(b);
-
             MainActivity.ShowFragment(getActivity(), "tracks", audioList);
         }
     };
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 2d577f3..905bb8a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -298,9 +298,9 @@ public class AudioBrowserListAdapter extends BaseAdapter implements ListAdapter
         // Return all the media locations of a list item list.
         ArrayList<String> locations = new ArrayList<String>();
         if (!mItems.get(position).mIsSeparator) {
-            ArrayList<Media> media = mItems.get(position).mMediaList;
-            for (int i = 0; i < media.size(); ++i)
-                locations.add(media.get(i).getLocation());
+            ArrayList<Media> mediaList = mItems.get(position).mMediaList;
+            for (int i = 0; i < mediaList.size(); ++i)
+                locations.add(mediaList.get(i).getLocation());
         }
         return locations;
     }
diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
index 4d39e43..1ac133e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioListFragment.java
@@ -235,26 +235,15 @@ public class AudioListFragment extends SherlockListFragment {
     };
 
     private void updateList() {
-        final Bundle b = getArguments();
-        String name = b.getString(EXTRA_NAME);
-        String name2 = b.getString(EXTRA_NAME2);
-        int mode = b.getInt(EXTRA_MODE, 0);
-
         List<Media> audioList;
         List<String> itemList;
         String currentItem = null;
         int currentIndex = -1;
 
-        if (name == null || mode == AudioBrowserFragment.MODE_SONG) {
-            mTitle.setText(R.string.songs);
-            itemList = mAudioController.getMediaLocations();
-            currentItem = mAudioController.getCurrentMediaLocation();
-            audioList = MediaLibrary.getInstance(getActivity()).getMediaItems(itemList);
-        }
-        else {
-            mTitle.setText(name2 != null ? name2 : name);
-            audioList = MediaLibrary.getInstance(getActivity()).getAudioItems(name, name2, mode);
-        }
+        mTitle.setText(R.string.songs);
+        itemList = mAudioController.getMediaLocations();
+        currentItem = mAudioController.getCurrentMediaLocation();
+        audioList = MediaLibrary.getInstance(getActivity()).getMediaItems(itemList);
 
         mSongsAdapter.clear();
         switch (mSortBy) {



More information about the Android mailing list