aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-09-23 15:44:40 -0700
committerScott Jackson <daneren2005@gmail.com>2014-09-23 15:44:40 -0700
commitb3ac5676687e039351877cd977a790869f066709 (patch)
tree98e5ae7331ee24e372334e5c7e973851507a608a /src/github
parent2729f4f410694721bc6ef973f7cab92f0497c827 (diff)
downloaddsub-b3ac5676687e039351877cd977a790869f066709.tar.gz
dsub-b3ac5676687e039351877cd977a790869f066709.tar.bz2
dsub-b3ac5676687e039351877cd977a790869f066709.zip
Add ability to pass in SilentBackgrounTask to getCoverArt/getAvatar for request cancellation
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/service/RESTMusicService.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/github/daneren2005/dsub/service/RESTMusicService.java b/src/github/daneren2005/dsub/service/RESTMusicService.java
index 53b20634..1f0c7e63 100644
--- a/src/github/daneren2005/dsub/service/RESTMusicService.java
+++ b/src/github/daneren2005/dsub/service/RESTMusicService.java
@@ -602,7 +602,7 @@ public class RESTMusicService implements MusicService {
}
@Override
- public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener) throws Exception {
+ public Bitmap getCoverArt(Context context, MusicDirectory.Entry entry, int size, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
// Synchronize on the entry so that we don't download concurrently for the same song.
synchronized (entry) {
@@ -619,7 +619,7 @@ public class RESTMusicService implements MusicService {
try {
List<String> parameterNames = Arrays.asList("id");
List<Object> parameterValues = Arrays.<Object>asList(entry.getCoverArt());
- HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener);
+ HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener, task);
in = entity.getContent();
Header contentEncoding = entity.getContentEncoding();
@@ -1291,7 +1291,7 @@ public class RESTMusicService implements MusicService {
}
@Override
- public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener) throws Exception {
+ public Bitmap getAvatar(String username, int size, Context context, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
// Return silently if server is too old
if (!ServerInfo.checkServerVersion(context, "1.8")) {
return null;
@@ -1316,7 +1316,7 @@ public class RESTMusicService implements MusicService {
parameterNames = Collections.singletonList("username");
parameterValues = Arrays.<Object>asList(username);
- HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener);
+ HttpEntity entity = getEntityForURL(context, url, null, parameterNames, parameterValues, progressListener, task);
in = entity.getContent();
Header contentEncoding = entity.getContentEncoding();
if (contentEncoding != null && contentEncoding.getValue().equalsIgnoreCase("gzip")) {
@@ -1490,9 +1490,14 @@ public class RESTMusicService implements MusicService {
return new InputStreamReader(in, Constants.UTF_8);
}
+ private HttpEntity getEntityForUrl(Context context, String url, HttpParams requestParams, List<String> parameterNames,
+ List<Ojbect> parameterValues, ProgressListener progressListener) throws Exception {
+
+ return getEntryForUrl(context, url, requestParams, parameterNames, parameterValues, progressListener, null);
+ }
private HttpEntity getEntityForURL(Context context, String url, HttpParams requestParams, List<String> parameterNames,
- List<Object> parameterValues, ProgressListener progressListener) throws Exception {
- return getResponseForURL(context, url, requestParams, parameterNames, parameterValues, null, progressListener, null).getEntity();
+ List<Object> parameterValues, ProgressListener progressListener, SilentBackgroundTask task) throws Exception {
+ return getResponseForURL(context, url, requestParams, parameterNames, parameterValues, null, progressListener, task).getEntity();
}
private HttpResponse getResponseForURL(Context context, String url, HttpParams requestParams,