From faa985bd481187ed6f569509f65e1f34a6e0b65e Mon Sep 17 00:00:00 2001 From: Adam Copp Date: Fri, 5 Oct 2012 16:38:07 +0100 Subject: 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 --- photoviewer/src/com/android/ex/photo/util/ImageUtils.java | 6 ++++++ 1 file changed, 6 insertions(+) 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); -- cgit v1.2.3