Made sure that fallback URL is used if MMR fails
This commit is contained in:
parent
99068c82cc
commit
40ef24d8ad
|
@ -76,19 +76,11 @@ public class PicassoProvider {
|
||||||
|
|
||||||
private static class MediaRequestHandler extends RequestHandler {
|
private static class MediaRequestHandler extends RequestHandler {
|
||||||
|
|
||||||
final MediaMetadataRetriever mmr;
|
|
||||||
final Context context;
|
final Context context;
|
||||||
|
|
||||||
public MediaRequestHandler(Context context) {
|
public MediaRequestHandler(Context context) {
|
||||||
super();
|
super();
|
||||||
this.context = context;
|
this.context = context;
|
||||||
mmr = new MediaMetadataRetriever();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void finalize() throws Throwable {
|
|
||||||
super.finalize();
|
|
||||||
mmr.release();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -99,11 +91,22 @@ public class PicassoProvider {
|
||||||
@Override
|
@Override
|
||||||
public Result load(Request data) throws IOException {
|
public Result load(Request data) throws IOException {
|
||||||
Bitmap bitmap = null;
|
Bitmap bitmap = null;
|
||||||
mmr.setDataSource(data.uri.getPath());
|
MediaMetadataRetriever mmr = null;
|
||||||
byte[] image = mmr.getEmbeddedPicture();
|
try {
|
||||||
if (image != null) {
|
mmr = new MediaMetadataRetriever();
|
||||||
bitmap = decodeStreamFromByteArray(data, image);
|
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) {
|
if (bitmap == null) {
|
||||||
// check for fallback Uri
|
// check for fallback Uri
|
||||||
String fallbackParam = data.uri.getQueryParameter(PicassoImageResource.PARAM_FALLBACK);
|
String fallbackParam = data.uri.getQueryParameter(PicassoImageResource.PARAM_FALLBACK);
|
||||||
|
|
Loading…
Reference in New Issue