aboutsummaryrefslogtreecommitdiff
path: root/subsonic-android/src/github
diff options
context:
space:
mode:
authorKurt Hardin <kurthardin.dev@gmail.com>2012-09-25 11:46:13 -0700
committerKurt Hardin <kurthardin.dev@gmail.com>2012-09-25 11:46:13 -0700
commit50cbd5040bfecfbad8b46694be17e6b793094c43 (patch)
tree78332a50920909a068180ef1d98c3427b38599ed /subsonic-android/src/github
parent72c741b2f3dd35c68c8a81f7d786de673e94f434 (diff)
downloaddsub-50cbd5040bfecfbad8b46694be17e6b793094c43.tar.gz
dsub-50cbd5040bfecfbad8b46694be17e6b793094c43.tar.bz2
dsub-50cbd5040bfecfbad8b46694be17e6b793094c43.zip
Added star support features for original UI.
Diffstat (limited to 'subsonic-android/src/github')
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java8
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java5
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/MusicService.java2
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java11
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java62
5 files changed, 87 insertions, 1 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
index 108dcf9c..8a473bc7 100644
--- a/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
+++ b/subsonic-android/src/github/daneren2005/dsub/activity/SelectAlbumActivity.java
@@ -336,7 +336,13 @@ public class SelectAlbumActivity extends SubsonicTabActivity {
new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
- return service.getAlbumList(albumListType, size, offset, SelectAlbumActivity.this, this);
+ MusicDirectory result;
+ if ("starred".equals(albumListType)) {
+ result = service.getStarredList(SelectAlbumActivity.this, this);
+ } else {
+ result = service.getAlbumList(albumListType, size, offset, SelectAlbumActivity.this, this);
+ }
+ return result;
}
@Override
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
index dbd421f2..832b2037 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/CachedMusicService.java
@@ -164,6 +164,11 @@ public class CachedMusicService implements MusicService {
}
@Override
+ public MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception {
+ return musicService.getStarredList(context, progressListener);
+ }
+
+ @Override
public MusicDirectory getRandomSongs(int size, Context context, ProgressListener progressListener) throws Exception {
return musicService.getRandomSongs(size, context, progressListener);
}
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
index a5045b18..15abbdf8 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/MusicService.java
@@ -53,6 +53,8 @@ public interface MusicService {
SearchResult search(SearchCritera criteria, Context context, ProgressListener progressListener) throws Exception;
+ MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception;
+
MusicDirectory getPlaylist(String id, String name, Context context, ProgressListener progressListener) throws Exception;
List<Playlist> getPlaylists(boolean refresh, Context context, ProgressListener progressListener) throws Exception;
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
index c24b2c06..1ef65bb8 100644
--- a/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/subsonic-android/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -93,6 +93,7 @@ import github.daneren2005.dsub.service.parser.PlaylistsParser;
import github.daneren2005.dsub.service.parser.RandomSongsParser;
import github.daneren2005.dsub.service.parser.SearchResult2Parser;
import github.daneren2005.dsub.service.parser.SearchResultParser;
+import github.daneren2005.dsub.service.parser.StarredListParser;
import github.daneren2005.dsub.service.parser.VersionParser;
import github.daneren2005.dsub.service.ssl.SSLSocketFactory;
import github.daneren2005.dsub.service.ssl.TrustSelfSignedStrategy;
@@ -415,6 +416,16 @@ public class RESTMusicService implements MusicService {
}
@Override
+ public MusicDirectory getStarredList(Context context, ProgressListener progressListener) throws Exception {
+ Reader reader = getReader(context, progressListener, "getStarred", null);
+ try {
+ return new StarredListParser(context).parse(reader, progressListener);
+ } finally {
+ Util.close(reader);
+ }
+ }
+
+ @Override
public MusicDirectory getRandomSongs(int size, Context context, ProgressListener progressListener) throws Exception {
HttpParams params = new BasicHttpParams();
HttpConnectionParams.setSoTimeout(params, SOCKET_READ_TIMEOUT_GET_RANDOM_SONGS);
diff --git a/subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java b/subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java
new file mode 100644
index 00000000..c3c16949
--- /dev/null
+++ b/subsonic-android/src/github/daneren2005/dsub/service/parser/StarredListParser.java
@@ -0,0 +1,62 @@
+/*
+ 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.service.parser;
+
+import android.content.Context;
+import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.ProgressListener;
+import org.xmlpull.v1.XmlPullParser;
+
+import java.io.Reader;
+
+/**
+ * @author Kurt Hardin
+ */
+public class StarredListParser extends MusicDirectoryEntryParser {
+
+ public StarredListParser(Context context) {
+ super(context);
+ }
+
+ public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
+
+ updateProgress(progressListener, R.string.parser_reading);
+ init(reader);
+
+ MusicDirectory dir = new MusicDirectory();
+ int eventType;
+ do {
+ eventType = nextParseEvent();
+ if (eventType == XmlPullParser.START_TAG) {
+ String name = getElementName();
+ if ("album".equals(name) || "song".equals(name)) {
+ dir.addChild(parseEntry());
+ } else if ("error".equals(name)) {
+ handleError();
+ }
+ }
+ } while (eventType != XmlPullParser.END_DOCUMENT);
+
+ validate();
+ updateProgress(progressListener, R.string.parser_reading_done);
+
+ return dir;
+ }
+} \ No newline at end of file