diff options
author | Adam Copp <adamcopp@google.com> | 2012-10-05 16:38:07 +0100 |
---|---|---|
committer | Adam Copp <adamcopp@google.com> | 2012-10-05 16:38:07 +0100 |
commit | faa985bd481187ed6f569509f65e1f34a6e0b65e (patch) | |
tree | a027b3c04775b8247da7aa2824f25cd5fdc12b36 /photoviewer | |
parent | da165c2e30ec1040419cded96a6248ccfe303a94 (diff) | |
download | android_frameworks_ex-faa985bd481187ed6f569509f65e1f34a6e0b65e.tar.gz android_frameworks_ex-faa985bd481187ed6f569509f65e1f34a6e0b65e.tar.bz2 android_frameworks_ex-faa985bd481187ed6f569509f65e1f34a6e0b65e.zip |
Temporary fix for image viewer crash
This fixes a bug causing the app to crash when we can't open a stream to
a url when we download an image.
Bug: 7294701
Change-Id: Ifd0c62c3f5bb6a168e2e2932734fa448ffb9344c
Diffstat (limited to 'photoviewer')
-rw-r--r-- | photoviewer/src/com/android/ex/photo/util/ImageUtils.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/photoviewer/src/com/android/ex/photo/util/ImageUtils.java b/photoviewer/src/com/android/ex/photo/util/ImageUtils.java index a932c8b..f37a1ad 100644 --- a/photoviewer/src/com/android/ex/photo/util/ImageUtils.java +++ b/photoviewer/src/com/android/ex/photo/util/ImageUtils.java @@ -100,6 +100,9 @@ public class ImageUtils { final BitmapFactory.Options opts = new BitmapFactory.Options(); final Point bounds = getImageBounds(resolver, uri); inputStream = openInputStream(resolver, uri); + if (bounds == null || inputStream == null) { + return null; + } opts.inSampleSize = Math.max(bounds.x / maxSize, bounds.y / maxSize); final Bitmap decodedBitmap = decodeStream(inputStream, null, opts); @@ -212,6 +215,9 @@ public class ImageUtils { try { opts.inJustDecodeBounds = true; inputStream = openInputStream(resolver, uri); + if (inputStream == null) { + return null; + } decodeStream(inputStream, null, opts); return new Point(opts.outWidth, opts.outHeight); |