aboutsummaryrefslogtreecommitdiff
path: root/app/src/main/java/github/daneren2005
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2016-02-04 17:12:57 -0800
committerScott Jackson <daneren2005@gmail.com>2016-02-04 17:12:57 -0800
commit2f7eaedf6a431d8e1677b7e0bfc129421cf90779 (patch)
treed5773fbfe37c27f4157ec209fceedd8b5a93c84e /app/src/main/java/github/daneren2005
parent8fffd752b4e1c7c1d20b8ebdfd68f69d8914051b (diff)
downloaddsub-2f7eaedf6a431d8e1677b7e0bfc129421cf90779.tar.gz
dsub-2f7eaedf6a431d8e1677b7e0bfc129421cf90779.tar.bz2
dsub-2f7eaedf6a431d8e1677b7e0bfc129421cf90779.zip
Change Top Tracks to display order instead of album's track
Diffstat (limited to 'app/src/main/java/github/daneren2005')
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java3
-rw-r--r--app/src/main/java/github/daneren2005/dsub/service/parser/TopSongsParser.java58
2 files changed, 60 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
index a7a68205..d258ec15 100644
--- a/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/app/src/main/java/github/daneren2005/dsub/service/RESTMusicService.java
@@ -96,6 +96,7 @@ import github.daneren2005.dsub.service.parser.SearchResult2Parser;
import github.daneren2005.dsub.service.parser.SearchResultParser;
import github.daneren2005.dsub.service.parser.ShareParser;
import github.daneren2005.dsub.service.parser.StarredListParser;
+import github.daneren2005.dsub.service.parser.TopSongsParser;
import github.daneren2005.dsub.service.parser.UserParser;
import github.daneren2005.dsub.service.parser.VideosParser;
import github.daneren2005.dsub.service.ssl.SSLSocketFactory;
@@ -1295,7 +1296,7 @@ public class RESTMusicService implements MusicService {
String method = ServerInfo.isMadsonic(context, getInstance(context)) ? "getTopTrackSongs" : "getTopSongs";
Reader reader = getReader(context, progressListener, method, null, parameterNames, parameterValues);
try {
- return new RandomSongsParser(context, getInstance(context)).parse(reader, progressListener);
+ return new TopSongsParser(context, getInstance(context)).parse(reader, progressListener);
} finally {
Util.close(reader);
}
diff --git a/app/src/main/java/github/daneren2005/dsub/service/parser/TopSongsParser.java b/app/src/main/java/github/daneren2005/dsub/service/parser/TopSongsParser.java
new file mode 100644
index 00000000..c3719782
--- /dev/null
+++ b/app/src/main/java/github/daneren2005/dsub/service/parser/TopSongsParser.java
@@ -0,0 +1,58 @@
+/*
+ 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 2016 (C) Scott Jackson
+*/
+package github.daneren2005.dsub.service.parser;
+
+import android.content.Context;
+
+import org.xmlpull.v1.XmlPullParser;
+
+import java.io.Reader;
+
+import github.daneren2005.dsub.domain.MusicDirectory;
+import github.daneren2005.dsub.util.ProgressListener;
+
+public class TopSongsParser extends MusicDirectoryEntryParser {
+
+ public TopSongsParser(Context context, int instance) {
+ super(context, instance);
+ }
+
+ public MusicDirectory parse(Reader reader, ProgressListener progressListener) throws Exception {
+ init(reader);
+
+ MusicDirectory dir = new MusicDirectory();
+ int eventType;
+ int trackNumber = 1;
+ do {
+ eventType = nextParseEvent();
+ if (eventType == XmlPullParser.START_TAG) {
+ String name = getElementName();
+ if ("song".equals(name)) {
+ MusicDirectory.Entry entry = parseEntry("");
+ entry.setTrack(trackNumber);
+ dir.addChild(entry);
+
+ trackNumber++;
+ } else if ("error".equals(name)) {
+ handleError();
+ }
+ }
+ } while (eventType != XmlPullParser.END_DOCUMENT);
+
+ validate();
+
+ return dir;
+ }
+} \ No newline at end of file