aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2012-11-10 20:43:57 -0800
committerScott Jackson <daneren2005@gmail.com>2012-11-10 20:43:57 -0800
commit2ded932e517a1b53f5f61297c5b062fadee30045 (patch)
treef613496eee9f0ecf4948afab60b84d0155683ddd /subsonic-android/src
parentf2bbdbe89234a0e0ac0991eac323a7fc0b729d59 (diff)
downloaddsub-2ded932e517a1b53f5f61297c5b062fadee30045.tar.gz
dsub-2ded932e517a1b53f5f61297c5b062fadee30045.tar.bz2
dsub-2ded932e517a1b53f5f61297c5b062fadee30045.zip
Made arrows on artist/albums/playlists clickable to quickly bring up context menus #47
Diffstat (limited to 'subsonic-android/src')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java1
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java9
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java9
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java81
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java60
5 files changed, 103 insertions, 57 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
index 84a10d08..a88cdcaf 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectPlaylistActivity.java
@@ -19,6 +19,7 @@
package github.daneren2005.dsub.activity;
+import github.daneren2005.dsub.view.PlaylistAdapter;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java b/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java
index 1636776c..6415984f 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/AlbumView.java
@@ -22,6 +22,7 @@ import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.MusicDirectory;
@@ -41,6 +42,7 @@ public class AlbumView extends UpdateView {
private TextView artistView;
private View coverArtView;
private ImageButton starButton;
+ private ImageView moreButton;
public AlbumView(Context context) {
super(context);
@@ -50,6 +52,13 @@ public class AlbumView extends UpdateView {
artistView = (TextView) findViewById(R.id.album_artist);
coverArtView = findViewById(R.id.album_coverart);
starButton = (ImageButton) findViewById(R.id.album_star);
+
+ moreButton = (ImageView) findViewById(R.id.album_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
}
public void setAlbum(MusicDirectory.Entry album, ImageLoader imageLoader) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java b/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java
index 8eaca821..86c39d14 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/ArtistView.java
@@ -22,10 +22,10 @@ import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageButton;
+import android.widget.ImageView;
import android.widget.TextView;
import github.daneren2005.dsub.R;
import github.daneren2005.dsub.domain.Artist;
-import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.util.Util;
/**
@@ -40,6 +40,7 @@ public class ArtistView extends UpdateView {
private TextView titleView;
private ImageButton starButton;
+ private ImageView moreButton;
public ArtistView(Context context) {
super(context);
@@ -47,6 +48,12 @@ public class ArtistView extends UpdateView {
titleView = (TextView) findViewById(R.id.artist_name);
starButton = (ImageButton) findViewById(R.id.artist_star);
+ moreButton = (ImageView) findViewById(R.id.artist_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
}
public void setArtist(Artist artist) {
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java
index 54379150..c9377721 100644
--- a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java
+++ b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistAdapter.java
@@ -14,77 +14,46 @@
You should have received a copy of the GNU General Public License
along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
- Copyright 2009 (C) Sindre Mehus
+ Copyright 2010 (C) Sindre Mehus
*/
package github.daneren2005.dsub.view;
-import android.content.Context;
-import android.widget.ArrayAdapter;
-import android.widget.SectionIndexer;
import github.daneren2005.dsub.R;
+import java.util.List;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import github.daneren2005.dsub.activity.SubsonicTabActivity;
import github.daneren2005.dsub.domain.Playlist;
-
-import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
-import java.util.LinkedHashSet;
-import java.util.List;
-import java.util.Set;
/**
-* @author Sindre Mehus
-* @version $Id$
-*/
-public class PlaylistAdapter extends ArrayAdapter<Playlist> implements SectionIndexer {
-
- // Both arrays are indexed by section ID.
- private final Object[] sections;
- private final Integer[] positions;
-
- /**
- * Note: playlists must be sorted alphabetically.
- */
- public PlaylistAdapter(Context context, List<Playlist> playlists) {
- super(context, R.layout.playlist_list_item, playlists);
-
- Set<String> sectionSet = new LinkedHashSet<String>(30);
- List<Integer> positionList = new ArrayList<Integer>(30);
- for (int i = 0; i < playlists.size(); i++) {
- Playlist playlist = playlists.get(i);
- if (playlist.getName().length() > 0) {
- String index = playlist.getName().substring(0, 1).toUpperCase();
- if (!sectionSet.contains(index)) {
- sectionSet.add(index);
- positionList.add(i);
- }
- }
- }
- sections = sectionSet.toArray(new Object[sectionSet.size()]);
- positions = positionList.toArray(new Integer[positionList.size()]);
- }
+ * @author Sindre Mehus
+ */
+public class PlaylistAdapter extends ArrayAdapter<Playlist> {
- @Override
- public Object[] getSections() {
- return sections;
- }
+ private final SubsonicTabActivity activity;
- @Override
- public int getPositionForSection(int section) {
- section = Math.min(section, positions.length - 1);
- return positions[section];
+ public PlaylistAdapter(SubsonicTabActivity activity, List<Playlist> Playlists) {
+ super(activity, R.layout.playlist_list_item, Playlists);
+ this.activity = activity;
}
@Override
- public int getSectionForPosition(int pos) {
- for (int i = 0; i < sections.length - 1; i++) {
- if (pos < positions[i + 1]) {
- return i;
- }
- }
- return sections.length - 1;
+ public View getView(int position, View convertView, ViewGroup parent) {
+ Playlist entry = getItem(position);
+ PlaylistView view;
+ if (convertView != null && convertView instanceof PlaylistView) {
+ view = (PlaylistView) convertView;
+ } else {
+ view = new PlaylistView(activity);
+ }
+ view.setPlaylist(entry);
+ return view;
}
-
- public static class PlaylistComparator implements Comparator<Playlist> {
+
+ public static class PlaylistComparator implements Comparator<Playlist> {
@Override
public int compare(Playlist playlist1, Playlist playlist2) {
return playlist1.getName().compareToIgnoreCase(playlist2.getName());
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
new file mode 100644
index 00000000..d1b9340a
--- /dev/null
+++ b/subsonic-android/src/github/daneren2005/dsub/view/PlaylistView.java
@@ -0,0 +1,60 @@
+/*
+ This file is part of Subsonic.
+
+ Subsonic is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ Subsonic is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with Subsonic. If not, see <http://www.gnu.org/licenses/>.
+
+ Copyright 2009 (C) Sindre Mehus
+ */
+package github.daneren2005.dsub.view;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.ImageView;
+import android.widget.TextView;
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.Playlist;
+
+/**
+ * Used to display albums in a {@code ListView}.
+ *
+ * @author Sindre Mehus
+ */
+public class PlaylistView extends UpdateView {
+ private static final String TAG = ArtistView.class.getSimpleName();
+
+ private Playlist playlist;
+
+ private TextView titleView;
+ private ImageView moreButton;
+
+ public PlaylistView(Context context) {
+ super(context);
+ LayoutInflater.from(context).inflate(R.layout.artist_list_item, this, true);
+
+ titleView = (TextView) findViewById(R.id.artist_name);
+ moreButton = (ImageView) findViewById(R.id.artist_more);
+ moreButton.setOnClickListener(new View.OnClickListener() {
+ public void onClick(View v) {
+ v.showContextMenu();
+ }
+ });
+ }
+
+ public void setPlaylist(Playlist playlist) {
+ this.playlist = playlist;
+
+ titleView.setText(playlist.getName());
+ }
+}