aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2014-07-28 19:21:49 -0700
committerScott Jackson <daneren2005@gmail.com>2014-07-28 19:21:49 -0700
commitdbc03b1be00abbec09204ea018f7d8e0e6d28a20 (patch)
tree77746da4fd43fc94375994069a68e499bffda780
parentc9291c24d7a0a0bf31b33ca0c12ec9a8c2dfebe5 (diff)
downloaddsub-dbc03b1be00abbec09204ea018f7d8e0e6d28a20.tar.gz
dsub-dbc03b1be00abbec09204ea018f7d8e0e6d28a20.tar.bz2
dsub-dbc03b1be00abbec09204ea018f7d8e0e6d28a20.zip
Fix web commit for ImageTask cancelling
-rw-r--r--src/github/daneren2005/dsub/util/ImageLoader.java18
-rw-r--r--src/github/daneren2005/dsub/view/UpdateView.java3
2 files changed, 14 insertions, 7 deletions
diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java
index cc85a2fb..ad016b6a 100644
--- a/src/github/daneren2005/dsub/util/ImageLoader.java
+++ b/src/github/daneren2005/dsub/util/ImageLoader.java
@@ -146,10 +146,12 @@ public class ImageLoader {
if (!large) {
setUnknownImage(view, large);
}
- return new ViewImageTask(view.getContext(), entry, size, imageSizeLarge, large, view, crossfade).execute();
+ ImageTask task = new ViewImageTask(view.getContext(), entry, size, imageSizeLarge, large, view, crossfade);
+ task.execute();
+ return task;
}
- public ImageTask loadImage(Context context, RemoteControlClient remoteControl, MusicDirectory.Entry entry) {
+ public SilentBackgroundTask<Void> loadImage(Context context, RemoteControlClient remoteControl, MusicDirectory.Entry entry) {
if (largeUnknownImage != null && ((BitmapDrawable)largeUnknownImage).getBitmap().isRecycled()) {
createLargeUnknownImage(context);
}
@@ -167,10 +169,12 @@ public class ImageLoader {
}
setUnknownImage(remoteControl);
- return new RemoteControlClientImageTask(context, entry, imageSizeLarge, imageSizeLarge, false, remoteControl).execute();
+ ImageTask task = new RemoteControlClientImageTask(context, entry, imageSizeLarge, imageSizeLarge, false, remoteControl);
+ task.execute();
+ return task;
}
- public ImageTask loadAvatar(Context context, ImageView view, String username) {
+ public SilentBackgroundTask<Void> loadAvatar(Context context, ImageView view, String username) {
Bitmap bitmap = cache.get(username);
if (bitmap != null && !bitmap.isRecycled()) {
Drawable drawable = Util.createDrawableFromBitmap(this.context, bitmap);
@@ -178,7 +182,9 @@ public class ImageLoader {
return null;
}
- return new AvatarTask(context, view, username).execute();
+ SilentBackgroundTask<Void> task = new AvatarTask(context, view, username);
+ task.execute();
+ return task;
}
private String getKey(String coverArtId, int size) {
@@ -205,7 +211,7 @@ public class ImageLoader {
} else if(existingDrawable instanceof TransitionDrawable) {
// This should only ever be used if user is skipping through many songs quickly
TransitionDrawable tmp = (TransitionDrawable) existingDrawable;
- exisitingDrawable = tmp.getDrawable(tmp.getNumberOfLayers() - 1);
+ existingDrawable = tmp.getDrawable(tmp.getNumberOfLayers() - 1);
}
Drawable[] layers = new Drawable[] {existingDrawable, drawable};
diff --git a/src/github/daneren2005/dsub/view/UpdateView.java b/src/github/daneren2005/dsub/view/UpdateView.java
index 9bcf5d08..f30ec42a 100644
--- a/src/github/daneren2005/dsub/view/UpdateView.java
+++ b/src/github/daneren2005/dsub/view/UpdateView.java
@@ -35,6 +35,7 @@ import java.util.WeakHashMap;
import github.daneren2005.dsub.util.ImageLoader;
import github.daneren2005.dsub.R;
+import github.daneren2005.dsub.util.SilentBackgroundTask;
public class UpdateView extends LinearLayout {
private static final String TAG = UpdateView.class.getSimpleName();
@@ -54,7 +55,7 @@ public class UpdateView extends LinearLayout {
protected boolean shaded = false;
protected boolean starred = false;
protected boolean isStarred = false;
- protected ImageLoader.ImageTask imageTask = null;
+ protected SilentBackgroundTask<Void> imageTask = null;
protected final boolean autoUpdate;