[Android] Audio browser: replace the old album panel by the new one

Adrien Maglo git at videolan.org
Mon Nov 25 14:17:18 CET 2013


vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Nov 25 14:17:10 2013 +0100| [6422cffe5ca9d44aeefbb35cfcf4548dad2c1057] | committer: Adrien Maglo

Audio browser: replace the old album panel by the new one

For now, the context menu does not work.

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

 vlc-android/res/layout/audio_browser.xml           |    4 +--
 .../vlc/gui/audio/AudioBrowserFragment.java        |   30 +++++++++++++++-----
 2 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/vlc-android/res/layout/audio_browser.xml b/vlc-android/res/layout/audio_browser.xml
index 60a6a8d..1094e45 100644
--- a/vlc-android/res/layout/audio_browser.xml
+++ b/vlc-android/res/layout/audio_browser.xml
@@ -87,16 +87,14 @@
             android:divider="?attr/item_divider"
             android:dividerHeight="1dp"
             android:fastScrollEnabled="true" />
-        <ExpandableListView
+        <ListView
             android:id="@+id/albums_list"
             android:layout_width="fill_parent"
             android:layout_height="fill_parent"
             android:paddingLeft="20dp"
             android:paddingRight="20dp"
             android:divider="?attr/item_divider"
-            android:childDivider="?attr/item_divider"
             android:dividerHeight="1dp"
-            android:groupIndicator="@null"
             android:fastScrollEnabled="true" />
        <ListView
             android:id="@+id/songs_list"
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 34bcc72..447457d 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -80,7 +80,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
 
     private AudioListAdapter mSongsAdapter;
     private AudioBrowserListAdapter mArtistsAdapter;
-    private AudioPlaylistAdapter mAlbumsAdapter;
+    private AudioBrowserListAdapter mAlbumsAdapter;
     private AudioPlaylistAdapter mGenresAdapter;
 
     public final static int SORT_BY_TITLE = 0;
@@ -107,7 +107,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
 
         mSongsAdapter = new AudioListAdapter(getActivity());
         mArtistsAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
-        mAlbumsAdapter = new AudioPlaylistAdapter(getActivity(), R.plurals.songs_quantity, R.plurals.songs_quantity);
+        mAlbumsAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
         mGenresAdapter = new AudioPlaylistAdapter(getActivity(), R.plurals.albums_quantity, R.plurals.songs_quantity);
     }
 
@@ -130,7 +130,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
 
         ListView songsList = (ListView)v.findViewById(R.id.songs_list);
         ListView artistList = (ListView)v.findViewById(R.id.artists_list);
-        ExpandableListView albumList = (ExpandableListView)v.findViewById(R.id.albums_list);
+        ListView albumList = (ListView)v.findViewById(R.id.albums_list);
         ExpandableListView genreList = (ExpandableListView)v.findViewById(R.id.genres_list);
 
         songsList.setAdapter(mSongsAdapter);
@@ -140,10 +140,9 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
 
         songsList.setOnItemClickListener(songListener);
         artistList.setOnItemClickListener(browserListListener);
-        albumList.setOnGroupClickListener(playlistListener);
+        albumList.setOnItemClickListener(albumListListener);
         genreList.setOnGroupClickListener(playlistListener);
 
-        albumList.setOnChildClickListener(playlistChildListener);
         genreList.setOnChildClickListener(playlistChildListener);
 
         registerForContextMenu(songsList);
@@ -253,6 +252,22 @@ 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();
+
+            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);
+        }
+    };
+
     @Override
     public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
         MenuInflater inflater = getActivity().getMenuInflater();
@@ -334,7 +349,8 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
                     medias = new ArrayList<String>();
                     break;
                 case MODE_ALBUM:
-                    medias = mAlbumsAdapter.getPlaylist(groupPosition, childPosition);
+                    //medias = mArtistsAdapter.getMedia(groupPosition);
+                    medias = new ArrayList<String>();
                     break;
                 case MODE_GENRE:
                     medias = mGenresAdapter.getPlaylist(groupPosition, childPosition);
@@ -525,9 +541,9 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
         Collections.sort(audioList, byAlbum);
         for (int i = 0; i < audioList.size(); i++) {
             Media media = audioList.get(i);
-            prevFirstLetter = addFirstLetterSeparator(mAlbumsAdapter, i, media.getAlbum(), prevFirstLetter);
             mAlbumsAdapter.add(media.getAlbum(), null, media);
         }
+        mAlbumsAdapter.addSeparators();
 
         Collections.sort(audioList, byGenre);
         for (int i = 0; i < audioList.size(); i++) {



More information about the Android mailing list