summaryrefslogtreecommitdiff
path: root/src/de/podfetcher/asynctask
diff options
context:
space:
mode:
authordaniel oeh <daniel.oeh@gmail.com>2012-07-11 12:10:46 +0200
committerdaniel oeh <daniel.oeh@gmail.com>2012-07-11 12:10:46 +0200
commite7f7838a9caa802837e0e055e0fed7794e6b6e69 (patch)
tree9c52c301db15ea96b5ba049e4a7ebf917c126b18 /src/de/podfetcher/asynctask
parent2c9a5ff54e0a1b6a1233776a07e8854f5082a8af (diff)
downloadAntennaPod-e7f7838a9caa802837e0e055e0fed7794e6b6e69.zip
Improved handling of invalid image file urls
Diffstat (limited to 'src/de/podfetcher/asynctask')
-rw-r--r--src/de/podfetcher/asynctask/FeedImageLoader.java26
1 files changed, 24 insertions, 2 deletions
diff --git a/src/de/podfetcher/asynctask/FeedImageLoader.java b/src/de/podfetcher/asynctask/FeedImageLoader.java
index c0dacd018..ce18aca50 100644
--- a/src/de/podfetcher/asynctask/FeedImageLoader.java
+++ b/src/de/podfetcher/asynctask/FeedImageLoader.java
@@ -1,8 +1,12 @@
package de.podfetcher.asynctask;
+import java.io.File;
+
import de.podfetcher.PodcastApp;
import de.podfetcher.R;
import de.podfetcher.feed.FeedImage;
+import de.podfetcher.feed.FeedManager;
+import de.podfetcher.storage.DownloadRequester;
import android.annotation.SuppressLint;
import android.app.ActivityManager;
import android.content.Context;
@@ -128,26 +132,44 @@ public class FeedImageLoader {
@Override
protected Void doInBackground(FeedImage... params) {
+ File f = null;
if (params[0].getFile_url() != null) {
+ f = new File(params[0].getFile_url());
+ }
+ if (params[0].getFile_url() != null && f.exists()) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inJustDecodeBounds = true;
BitmapFactory.decodeFile(params[0].getFile_url(), options);
int sampleSize = calculateSampleSize(options.outWidth,
options.outHeight);
-
+
options.inJustDecodeBounds = false;
options.inSampleSize = sampleSize;
decodedBitmap = BitmapFactory.decodeFile(
params[0].getFile_url(), options);
+ if (decodedBitmap == null) {
+ Log.i(TAG,
+ "Bitmap could not be decoded in custom sample size. Trying default sample size (path was "
+ + params[0].getFile_url() + ")");
+ decodedBitmap = BitmapFactory.decodeFile(params[0]
+ .getFile_url());
+ }
bitmap = Bitmap.createScaledBitmap(decodedBitmap,
PREFERRED_LENGTH, PREFERRED_LENGTH, false);
addBitmapToCache(params[0].getId(), bitmap);
Log.d(TAG, "Finished loading bitmaps");
} else {
- Log.e(TAG, "FeedImage has no file url. Using default image");
+ Log.e(TAG,
+ "FeedImage has no valid file url. Using default image");
bitmap = BitmapFactory.decodeResource(target.getResources(),
R.drawable.default_cover);
+ if (params[0].getFile_url() != null
+ && !DownloadRequester.getInstance().isDownloadingFile(
+ params[0])) {
+ FeedManager.getInstance().notifyInvalidImageFile(
+ PodcastApp.getInstance(), params[0]);
+ }
}
return null;
}