diff options
author | Scott Jackson <daneren2005@gmail.com> | 2014-01-20 10:51:11 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2014-01-20 10:51:11 -0800 |
commit | eb061b6b1bfc365dd8fc5439d2bb00fa28a02bf0 (patch) | |
tree | 4afea692eac7e885bd3cd7aeb8f549bd572d4060 /src | |
parent | a5676557bcb659e917c972905440676ee6062a89 (diff) | |
download | dsub-eb061b6b1bfc365dd8fc5439d2bb00fa28a02bf0.tar.gz dsub-eb061b6b1bfc365dd8fc5439d2bb00fa28a02bf0.tar.bz2 dsub-eb061b6b1bfc365dd8fc5439d2bb00fa28a02bf0.zip |
Abstract getting music dir, use it for cache command
Diffstat (limited to 'src')
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java | 21 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/fragments/SubsonicFragment.java | 16 |
2 files changed, 17 insertions, 20 deletions
diff --git a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java index 0b58c618..eae48ca0 100644 --- a/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java +++ b/src/github/daneren2005/dsub/fragments/SelectDirectoryFragment.java @@ -68,7 +68,6 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter int albumListSize;
boolean refreshListing = false;
boolean showAll = false;
- boolean artist = false;
public SelectDirectoryFragment() {
@@ -395,15 +394,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter new LoadTask() {
@Override
protected MusicDirectory load(MusicService service) throws Exception {
- if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
- if(artist) {
- return service.getArtist(id, name, refresh, context, this);
- } else {
- return service.getAlbum(id, name, refresh, context, this);
- }
- } else {
- return service.getMusicDirectory(id, name, refresh, context, this);
- }
+ return getMusicDirectory(id, name, refresh, service, this);
}
@Override
@@ -422,15 +413,7 @@ public class SelectDirectoryFragment extends SubsonicFragment implements Adapter protected MusicDirectory load(MusicService service) throws Exception {
MusicDirectory root;
if(share == null) {
- if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
- if(artist) {
- root = service.getArtist(id, name, refresh, context, this);
- } else {
- root = service.getAlbum(id, name, refresh, context, this);
- }
- } else {
- root = service.getMusicDirectory(id, name, refresh, context, this);
- }
+ root = getMusicDirectory(id, name, refresh, service, this);
} else {
root = share.getMusicDirectory();
}
diff --git a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java index 8907a534..1504b7a4 100644 --- a/src/github/daneren2005/dsub/fragments/SubsonicFragment.java +++ b/src/github/daneren2005/dsub/fragments/SubsonicFragment.java @@ -62,6 +62,7 @@ import github.daneren2005.dsub.service.ServerTooOldException; import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.ImageLoader;
+import github.daneren2005.dsub.util.ProgressListener;
import github.daneren2005.dsub.util.SilentBackgroundTask;
import github.daneren2005.dsub.util.LoadingTask;
import github.daneren2005.dsub.util.Util;
@@ -92,6 +93,7 @@ public class SubsonicFragment extends Fragment { protected static Random random = new Random();
protected GestureDetector gestureScanner;
protected Share share;
+ protected boolean artist = false;
public SubsonicFragment() {
super();
@@ -685,7 +687,7 @@ public class SubsonicFragment extends Fragment { root = share.getMusicDirectory();
}
else if(isDirectory) {
- root = musicService.getMusicDirectory(id, name, false, context, this);
+ root = getMusicDirectory(id, name, false, musicService, this);
}
else {
root = musicService.getPlaylist(true, id, name, context, this);
@@ -735,6 +737,18 @@ public class SubsonicFragment extends Fragment { task.execute();
}
+ protected MusicDirectory getMusicDirectory(String id, String name, boolean refresh, MusicService service, ProgressListener listener) throws Exception {
+ if(Util.isTagBrowsing(context) && !Util.isOffline(context)) {
+ if(artist) {
+ return service.getArtist(id, name, refresh, context, listener);
+ } else {
+ return service.getAlbum(id, name, refresh, context, listener);
+ }
+ } else {
+ return service.getMusicDirectory(id, name, refresh, context, listener);
+ }
+ }
+
protected void addToPlaylist(final List<MusicDirectory.Entry> songs) {
if(songs.isEmpty()) {
Util.toast(context, "No songs selected");
|