summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java')
-rw-r--r--src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java b/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java
index c23c4c66a..810a17165 100644
--- a/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java
+++ b/src/de/danoeh/antennapod/asynctask/BitmapDecodeWorkerTask.java
@@ -11,10 +11,10 @@ import de.danoeh.antennapod.AppConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.util.BitmapDecoder;
-public abstract class BitmapDecodeWorkerTask extends Thread {
+public class BitmapDecodeWorkerTask extends Thread {
protected int PREFERRED_LENGTH;
-
+
/** Can be thumbnail or cover */
protected int imageType;
@@ -25,7 +25,7 @@ public abstract class BitmapDecodeWorkerTask extends Thread {
protected String fileUrl;
private Handler handler;
-
+
private final int defaultCoverResource;
public BitmapDecodeWorkerTask(Handler handler, ImageView target,
@@ -36,7 +36,8 @@ public abstract class BitmapDecodeWorkerTask extends Thread {
this.fileUrl = fileUrl;
this.PREFERRED_LENGTH = length;
this.imageType = imageType;
- TypedArray res = target.getContext().obtainStyledAttributes(new int[] {R.attr.default_cover});
+ TypedArray res = target.getContext().obtainStyledAttributes(
+ new int[] { R.attr.default_cover });
this.defaultCoverResource = res.getResourceId(0, 0);
res.recycle();
}
@@ -45,7 +46,9 @@ public abstract class BitmapDecodeWorkerTask extends Thread {
* Should return true if tag of the imageview is still the same it was
* before the bitmap was decoded
*/
- abstract protected boolean tagsMatching(ImageView target);
+ protected boolean tagsMatching(ImageView target) {
+ return target.getTag() == null || target.getTag() == fileUrl;
+ }
protected void onPostExecute() {
// check if imageview is still supposed to display this image
@@ -64,13 +67,15 @@ public abstract class BitmapDecodeWorkerTask extends Thread {
f = new File(fileUrl);
}
if (fileUrl != null && f.exists()) {
- cBitmap = new CachedBitmap(BitmapDecoder.decodeBitmap(PREFERRED_LENGTH, fileUrl), PREFERRED_LENGTH);
+ cBitmap = new CachedBitmap(BitmapDecoder.decodeBitmap(
+ PREFERRED_LENGTH, fileUrl), PREFERRED_LENGTH);
if (cBitmap.getBitmap() != null) {
storeBitmapInCache(cBitmap);
} else {
Log.w(TAG, "Could not load bitmap. Using default image.");
- cBitmap = new CachedBitmap(BitmapFactory.decodeResource(target.getResources(),
- defaultCoverResource), PREFERRED_LENGTH);
+ cBitmap = new CachedBitmap(BitmapFactory.decodeResource(
+ target.getResources(), defaultCoverResource),
+ PREFERRED_LENGTH);
}
if (AppConfig.DEBUG)
Log.d(TAG, "Finished loading bitmaps");
@@ -98,15 +103,15 @@ public abstract class BitmapDecodeWorkerTask extends Thread {
protected void onInvalidFileUrl() {
Log.e(TAG, "FeedImage has no valid file url. Using default image");
- cBitmap = new CachedBitmap(BitmapFactory.decodeResource(target.getResources(),
- defaultCoverResource), PREFERRED_LENGTH);
+ cBitmap = new CachedBitmap(BitmapFactory.decodeResource(
+ target.getResources(), defaultCoverResource), PREFERRED_LENGTH);
}
protected void storeBitmapInCache(CachedBitmap cb) {
- FeedImageLoader loader = FeedImageLoader.getInstance();
- if (imageType == FeedImageLoader.IMAGE_TYPE_COVER) {
+ ImageLoader loader = ImageLoader.getInstance();
+ if (imageType == ImageLoader.IMAGE_TYPE_COVER) {
loader.addBitmapToCoverCache(fileUrl, cb);
- } else if (imageType == FeedImageLoader.IMAGE_TYPE_THUMBNAIL) {
+ } else if (imageType == ImageLoader.IMAGE_TYPE_THUMBNAIL) {
loader.addBitmapToThumbnailCache(fileUrl, cb);
}
}