diff options
author | Christian Schneppe <christian@pix-art.de> | 2017-11-21 20:19:30 +0100 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2017-11-21 20:19:30 +0100 |
commit | 47b6cbe5dfcde17947fc5b6db962b180be2d2192 (patch) | |
tree | 62e29275dda8de8265178f9c3063bc9b4239e264 /src/main | |
parent | 61235080d19516a52f1a1862d22257928e9722f0 (diff) |
catch all RuntimeExceptions when using MetadataRetriever
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/persistance/FileBackend.java | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java index 79e8980e9..0db865236 100644 --- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java +++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java @@ -529,7 +529,7 @@ public class FileBackend { frame = metadataRetriever.getFrameAtTime(0); metadataRetriever.release(); frame = resize(frame, size); - } catch (IllegalArgumentException | NullPointerException e) { + } catch(RuntimeException e) { frame = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888); frame.eraseColor(0xff000000); } @@ -871,7 +871,7 @@ public class FileBackend { MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); mediaMetadataRetriever.setDataSource(file.toString()); return Integer.parseInt(mediaMetadataRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION)); - } catch (IllegalArgumentException e) { + } catch (RuntimeException e) { return 0; } } @@ -939,7 +939,7 @@ public class FileBackend { MediaMetadataRetriever metadataRetriever = new MediaMetadataRetriever(); try { metadataRetriever.setDataSource(file.getAbsolutePath()); - } catch (Exception e) { + } catch (RuntimeException e) { throw new NotAVideoFile(e); } return getVideoDimensions(metadataRetriever); @@ -949,7 +949,11 @@ public class FileBackend { private static Dimensions getVideoDimensions(Context context, Uri uri) throws NotAVideoFile { MediaMetadataRetriever mediaMetadataRetriever = new MediaMetadataRetriever(); try { - mediaMetadataRetriever.setDataSource(context, uri); + try { + mediaMetadataRetriever.setDataSource(context, uri); + } catch (RuntimeException e) { + throw new NotAVideoFile(e); + } } catch (Exception e) { throw new NotAVideoFile(); } |