summaryrefslogtreecommitdiff
path: root/src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-08-03 15:02:48 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-08-03 15:02:48 +0200
commit24775b9163326e01ffc7c5114597e579b4134ad7 (patch)
treee0f89663f0aaa39ad386a9641b22fb49e7ef6f5f /src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java
parent7ada4c2efb411d0eddcca315a164da0d7c3984a6 (diff)
downloadAntennaPod-24775b9163326e01ffc7c5114597e579b4134ad7.zip
Created AsyncTask for loading miroguide thumbnails from the disk cache
Diffstat (limited to 'src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java')
-rw-r--r--src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java34
1 files changed, 9 insertions, 25 deletions
diff --git a/src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java b/src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java
index c1a87b1ec..00776c4a2 100644
--- a/src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java
+++ b/src/de/danoeh/antennapod/asynctask/MiroGuideThumbnailDownloader.java
@@ -18,10 +18,7 @@ import de.danoeh.antennapod.PodcastApp;
import de.danoeh.antennapod.miroguide.model.MiroChannel;
import de.danoeh.antennapod.util.BitmapDecoder;
-import android.content.Context;
-import android.content.pm.PackageManager.NameNotFoundException;
import android.graphics.Bitmap;
-import android.os.AsyncTask;
import android.util.Log;
import android.widget.ImageView;
@@ -29,12 +26,8 @@ import android.widget.ImageView;
public class MiroGuideThumbnailDownloader extends BitmapDecodeWorkerTask {
private static final String TAG = "MiroGuideThumbnailDownloader";
- private static final String CACHE_DIR = "miroguide_thumbnails";
- private static final int CACHE_SIZE = 20 * 1024 * 1024;
- private static final int VALUE_SIZE = 500 * 1024;
-
private Exception exception;
-
+
private MiroChannel miroChannel;
public MiroGuideThumbnailDownloader(ImageView target,
@@ -43,14 +36,13 @@ public class MiroGuideThumbnailDownloader extends BitmapDecodeWorkerTask {
this.miroChannel = miroChannel;
}
- private static DiskLruCache openThubmnailDiskCache()
- throws NameNotFoundException, IOException {
- Context appContext = PodcastApp.getInstance();
- return DiskLruCache.open(
- appContext.getExternalFilesDir(CACHE_DIR),
- appContext.getPackageManager().getPackageInfo(
- appContext.getPackageName(), 0).versionCode,
- VALUE_SIZE, CACHE_SIZE);
+ @Override
+ protected void onPostExecute(Void result) {
+ if (exception != null) {
+ super.onPostExecute(result);
+ } else {
+ Log.e(TAG, "Failed to download thumbnail");
+ }
}
@Override
@@ -66,7 +58,7 @@ public class MiroGuideThumbnailDownloader extends BitmapDecodeWorkerTask {
File destination = new File(PodcastApp.getInstance().getCacheDir(),
Integer.toString(fileUrl.hashCode()));
try {
- DiskLruCache diskCache = openThubmnailDiskCache();
+ DiskLruCache diskCache = FeedImageLoader.openThubmnailDiskCache();
Editor editor = diskCache.edit(fileUrl);
if (editor != null) {
HttpURLConnection connection = (HttpURLConnection) url
@@ -100,9 +92,6 @@ public class MiroGuideThumbnailDownloader extends BitmapDecodeWorkerTask {
} catch (IOException e) {
e.printStackTrace();
return null;
- } catch (NameNotFoundException e) {
- e.printStackTrace();
- return null;
} finally {
if (destination.exists()) {
destination.delete();
@@ -115,9 +104,4 @@ public class MiroGuideThumbnailDownloader extends BitmapDecodeWorkerTask {
protected boolean tagsMatching(ImageView target) {
return target.getTag() == null || target.getTag() == miroChannel;
}
-
- @Override
- protected void storeBitmapInCache(Bitmap bitmap) {
-
- }
}