From dbc03b1be00abbec09204ea018f7d8e0e6d28a20 Mon Sep 17 00:00:00 2001 From: Scott Jackson Date: Mon, 28 Jul 2014 19:21:49 -0700 Subject: Fix web commit for ImageTask cancelling --- src/github/daneren2005/dsub/util/ImageLoader.java | 18 ++++++++++++------ src/github/daneren2005/dsub/view/UpdateView.java | 3 ++- 2 files changed, 14 insertions(+), 7 deletions(-) (limited to 'src/github/daneren2005') 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 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 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 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 imageTask = null; protected final boolean autoUpdate; -- cgit v1.2.3