[Android] Audio browser: replace the old genre panel by the new one
Adrien Maglo
git at videolan.org
Mon Nov 25 15:01:55 CET 2013
vlc-ports/android | branch: master | Adrien Maglo <magsoft at videolan.org> | Mon Nov 25 15:01:40 2013 +0100| [131aa7c3939a84b9b5bd98d24b5214976f817035] | committer: Adrien Maglo
Audio browser: replace the old genre 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=131aa7c3939a84b9b5bd98d24b5214976f817035
---
vlc-android/res/layout/audio_browser.xml | 4 +-
.../vlc/gui/audio/AudioBrowserFragment.java | 79 ++++----------------
2 files changed, 17 insertions(+), 66 deletions(-)
diff --git a/vlc-android/res/layout/audio_browser.xml b/vlc-android/res/layout/audio_browser.xml
index 1094e45..3f998ac 100644
--- a/vlc-android/res/layout/audio_browser.xml
+++ b/vlc-android/res/layout/audio_browser.xml
@@ -105,16 +105,14 @@
android:divider="?attr/item_divider"
android:dividerHeight="1dp"
android:fastScrollEnabled="true" />
- <ExpandableListView
+ <ListView
android:id="@+id/genres_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" />
</org.videolan.vlc.widget.FlingViewGroup>
</LinearLayout>
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 569ae37..04768ef 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserFragment.java
@@ -59,8 +59,6 @@ import android.widget.AdapterView.AdapterContextMenuInfo;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
-import android.widget.ExpandableListView.OnChildClickListener;
-import android.widget.ExpandableListView.OnGroupClickListener;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -81,7 +79,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
private AudioBrowserListAdapter mSongsAdapter;
private AudioBrowserListAdapter mArtistsAdapter;
private AudioBrowserListAdapter mAlbumsAdapter;
- private AudioPlaylistAdapter mGenresAdapter;
+ private AudioBrowserListAdapter mGenresAdapter;
public final static int SORT_BY_TITLE = 0;
public final static int SORT_BY_LENGTH = 1;
@@ -108,7 +106,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
mSongsAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
mArtistsAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
mAlbumsAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITH_COVER);
- mGenresAdapter = new AudioPlaylistAdapter(getActivity(), R.plurals.albums_quantity, R.plurals.songs_quantity);
+ mGenresAdapter = new AudioBrowserListAdapter(getActivity(), AudioBrowserListAdapter.ITEM_WITHOUT_COVER);
}
@Override
@@ -131,7 +129,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);
ListView albumList = (ListView)v.findViewById(R.id.albums_list);
- ExpandableListView genreList = (ExpandableListView)v.findViewById(R.id.genres_list);
+ ListView genreList = (ListView)v.findViewById(R.id.genres_list);
songsList.setAdapter(mSongsAdapter);
artistList.setAdapter(mArtistsAdapter);
@@ -141,9 +139,7 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
songsList.setOnItemClickListener(songListener);
artistList.setOnItemClickListener(artistListListener);
albumList.setOnItemClickListener(albumListListener);
- genreList.setOnGroupClickListener(playlistListener);
-
- genreList.setOnChildClickListener(playlistChildListener);
+ genreList.setOnItemClickListener(genreListListener);
registerForContextMenu(songsList);
registerForContextMenu(artistList);
@@ -205,46 +201,6 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
}
};
- OnGroupClickListener playlistListener = new OnGroupClickListener() {
- @Override
- public boolean onGroupClick(ExpandableListView elv, View v, int groupPosition, long id) {
- AudioPlaylistAdapter adapter = (AudioPlaylistAdapter) elv.getExpandableListAdapter();
- if (adapter.getChildrenCount(groupPosition) > 2)
- return false;
-
- String name = adapter.getGroup(groupPosition);
-
- 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, mFlingViewGroup.getPosition());
- audioList.setArguments(b);
-
- MainActivity.ShowFragment(getActivity(), "tracks", audioList);
- return true;
- }
- };
-
- OnChildClickListener playlistChildListener = new OnChildClickListener() {
- @Override
- public boolean onChildClick(ExpandableListView elv, View v, int groupPosition, int childPosition, long id) {
- AudioPlaylistAdapter adapter = (AudioPlaylistAdapter) elv.getExpandableListAdapter();
- String name = adapter.getGroup(groupPosition);
- String child = adapter.getChild(groupPosition, childPosition);
-
- AudioListFragment audioList = new AudioListFragment();
- Bundle b = new Bundle();
- b.putString(AudioListFragment.EXTRA_NAME, name);
- b.putString(AudioListFragment.EXTRA_NAME2, child);
- b.putInt(AudioListFragment.EXTRA_MODE, mFlingViewGroup.getPosition());
- audioList.setArguments(b);
-
- MainActivity.ShowFragment(getActivity(), "tracks", audioList);
- return false;
- }
- };
-
OnItemClickListener artistListListener = new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> av, View v, int p, long id) {
@@ -270,6 +226,15 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
}
};
+ OnItemClickListener genreListListener = new OnItemClickListener() {
+ @Override
+ public void onItemClick(AdapterView<?> av, View v, int p, long id) {
+ ArrayList<Media> mediaList = mGenresAdapter.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();
@@ -357,7 +322,8 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
medias = new ArrayList<String>();
break;
case MODE_GENRE:
- medias = mGenresAdapter.getPlaylist(groupPosition, childPosition);
+ //medias = mGenresAdapter.getMedia(groupPosition);
+ medias = new ArrayList<String>();
break;
default:
return true;
@@ -537,8 +503,6 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
if (mSortBy != SORT_BY_LENGTH)
mSongsAdapter.addSeparators();
- char prevFirstLetter = 'A';
-
Collections.sort(audioList, byArtist);
for (int i = 0; i < audioList.size(); i++) {
Media media = audioList.get(i);
@@ -556,10 +520,9 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
Collections.sort(audioList, byGenre);
for (int i = 0; i < audioList.size(); i++) {
Media media = audioList.get(i);
- prevFirstLetter = addFirstLetterSeparator(mGenresAdapter, i, media.getGenre(), prevFirstLetter);
mGenresAdapter.add(media.getGenre(), null, media);
- mGenresAdapter.add(media.getGenre(), media.getAlbum(), media);
}
+ mGenresAdapter.addSeparators();
mSongsAdapter.notifyDataSetChanged();
mArtistsAdapter.notifyDataSetChanged();
@@ -567,16 +530,6 @@ public class AudioBrowserFragment extends SherlockFragment implements ISortable
mGenresAdapter.notifyDataSetChanged();
}
- private final char addFirstLetterSeparator(AudioPlaylistAdapter list, int i, String tittle, char prevFirstLetter) {
- char firstLetter = tittle.toUpperCase().charAt(0);
- if (Character.isLetter(firstLetter)
- && (i == 0 || firstLetter != prevFirstLetter)) {
- list.addSeparator(String.valueOf(firstLetter));
- prevFirstLetter = firstLetter;
- }
- return prevFirstLetter;
- }
-
@Override
public void sortBy(int sortby) {
if(mSortBy == sortby) {
More information about the Android
mailing list