diff options
author | daniel oeh <daniel.oeh@gmail.com> | 2014-11-12 12:08:31 +0100 |
---|---|---|
committer | daniel oeh <daniel.oeh@gmail.com> | 2014-11-12 12:08:31 +0100 |
commit | 40ef24d8ad739ae375089530865149191f2b44f0 (patch) | |
tree | 8bcfe266f33df3029b65487260754b8d5b358d3c /core/src/main | |
parent | 99068c82ccf1ac03153e5eb6e79ff2c610caf3cf (diff) | |
download | AntennaPod-40ef24d8ad739ae375089530865149191f2b44f0.zip |
Made sure that fallback URL is used if MMR fails
Diffstat (limited to 'core/src/main')
-rw-r--r-- | core/src/main/java/de/danoeh/antennapod/core/asynctask/PicassoProvider.java | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/core/src/main/java/de/danoeh/antennapod/core/asynctask/PicassoProvider.java b/core/src/main/java/de/danoeh/antennapod/core/asynctask/PicassoProvider.java index 6d9353a93..1ed29c23a 100644 --- a/core/src/main/java/de/danoeh/antennapod/core/asynctask/PicassoProvider.java +++ b/core/src/main/java/de/danoeh/antennapod/core/asynctask/PicassoProvider.java @@ -76,19 +76,11 @@ public class PicassoProvider { private static class MediaRequestHandler extends RequestHandler { - final MediaMetadataRetriever mmr; final Context context; public MediaRequestHandler(Context context) { super(); this.context = context; - mmr = new MediaMetadataRetriever(); - } - - @Override - protected void finalize() throws Throwable { - super.finalize(); - mmr.release(); } @Override @@ -99,11 +91,22 @@ public class PicassoProvider { @Override public Result load(Request data) throws IOException { Bitmap bitmap = null; - mmr.setDataSource(data.uri.getPath()); - byte[] image = mmr.getEmbeddedPicture(); - if (image != null) { - bitmap = decodeStreamFromByteArray(data, image); + MediaMetadataRetriever mmr = null; + try { + mmr = new MediaMetadataRetriever(); + mmr.setDataSource(data.uri.getPath()); + byte[] image = mmr.getEmbeddedPicture(); + if (image != null) { + bitmap = decodeStreamFromByteArray(data, image); + } + } catch (RuntimeException e) { + Log.e(TAG, "Failed to decode image in media file", e); + } finally { + if (mmr != null) { + mmr.release(); + } } + if (bitmap == null) { // check for fallback Uri String fallbackParam = data.uri.getQueryParameter(PicassoImageResource.PARAM_FALLBACK); |