diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-05-28 21:38:20 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-05-28 21:38:20 -0700 |
commit | 4bbe30d40b3020db61aa5d26e1805edffd59a558 (patch) | |
tree | ba0757bea1593e4917de9febccb38d6980920a9a /subsonic-android/src/github/daneren2005 | |
parent | 061b5f8a6107a635ba669bdde1dbf07fae001d50 (diff) | |
download | dsub-4bbe30d40b3020db61aa5d26e1805edffd59a558.tar.gz dsub-4bbe30d40b3020db61aa5d26e1805edffd59a558.tar.bz2 dsub-4bbe30d40b3020db61aa5d26e1805edffd59a558.zip |
Starred artist support
Diffstat (limited to 'subsonic-android/src/github/daneren2005')
5 files changed, 110 insertions, 6 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java index b80e71ca..b0434aca 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/MusicDirectoryEntryParser.java @@ -59,4 +59,16 @@ public class MusicDirectoryEntryParser extends AbstractParser { } return entry; } + + protected MusicDirectory.Entry parseArtist() { + MusicDirectory.Entry entry = new MusicDirectory.Entry(); + + entry.setId(get("id")); + entry.setTitle(get("name")); + entry.setPath(entry.getTitle()); + entry.setStarred(true); + entry.setDirectory(true); + + return entry; + } }
\ No newline at end of file diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java index 2cb42f30..fc4cd175 100644 --- a/subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java +++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java @@ -49,7 +49,7 @@ public class StarredListParser extends MusicDirectoryEntryParser { if ("album".equals(name) || "song".equals(name)) { dir.addChild(parseEntry("")); } else if("artist".equals(name)) { - + dir.addChild(parseArtist()); } else if ("error".equals(name)) { handleError(); } diff --git a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java index 65f5a37f..7ead874c 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/FileUtil.java @@ -129,6 +129,10 @@ public class FileUtil { File dir = new File(getMusicDirectory(context).getPath() + "/" + fileSystemSafe(artist.getName())); return dir; } + public static File getArtistDirectory(Context context, MusicDirectory.Entry artist) { + File dir = new File(getMusicDirectory(context).getPath() + "/" + fileSystemSafe(artist.getTitle())); + return dir; + } public static File getAlbumDirectory(Context context, MusicDirectory.Entry entry) { File dir; diff --git a/subsonic-android/src/github/daneren2005/dsub/view/ArtistEntryView.java b/subsonic-android/src/github/daneren2005/dsub/view/ArtistEntryView.java new file mode 100644 index 00000000..3b6a50e4 --- /dev/null +++ b/subsonic-android/src/github/daneren2005/dsub/view/ArtistEntryView.java @@ -0,0 +1,83 @@ +/*
+ 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.util.Log;
+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;
+import github.daneren2005.dsub.util.FileUtil;
+import github.daneren2005.dsub.util.ImageLoader;
+import github.daneren2005.dsub.util.Util;
+import java.io.File;
+/**
+ * Used to display albums in a {@code ListView}.
+ *
+ * @author Sindre Mehus
+ */
+public class ArtistEntryView extends UpdateView {
+ private static final String TAG = AlbumView.class.getSimpleName();
+
+ private Context context;
+ private MusicDirectory.Entry artist;
+
+ private TextView titleView;
+ private ImageButton starButton;
+ private ImageView moreButton;
+
+ public ArtistEntryView(Context context) {
+ super(context);
+ this.context = context;
+ LayoutInflater.from(context).inflate(R.layout.artist_list_item, this, true);
+
+ 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(MusicDirectory.Entry artist) {
+ this.artist = artist;
+
+ titleView.setText(artist.getTitle());
+ starButton.setVisibility((Util.isOffline(getContext()) || !artist.isStarred()) ? View.GONE : View.VISIBLE);
+ starButton.setFocusable(false);
+ update();
+ }
+
+ @Override
+ protected void update() {
+ starButton.setVisibility((Util.isOffline(getContext()) || !artist.isStarred()) ? View.GONE : View.VISIBLE);
+ File file = FileUtil.getArtistDirectory(context, artist);
+ if(file.exists()) {
+ moreButton.setImageResource(R.drawable.list_item_more_shaded);
+ } else {
+ moreButton.setImageResource(R.drawable.list_item_more);
+ }
+ }
+}
diff --git a/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java b/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java index 0d67c4c4..1a4544e0 100644 --- a/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java +++ b/subsonic-android/src/github/daneren2005/dsub/view/EntryAdapter.java @@ -54,11 +54,16 @@ public class EntryAdapter extends ArrayAdapter<MusicDirectory.Entry> { MusicDirectory.Entry entry = getItem(position); if (entry.isDirectory()) { - AlbumView view; - view = new AlbumView(activity); - view.setAlbum(entry, imageLoader); - return view; - + if(entry.getParent() != null) { + AlbumView view; + view = new AlbumView(activity); + view.setAlbum(entry, imageLoader); + return view; + } else { + ArtistEntryView view = new ArtistEntryView(activity); + view.setArtist(entry); + return view; + } } else { SongView view; if (convertView != null && convertView instanceof SongView) { |