summaryrefslogtreecommitdiffstats
path: root/photoviewer
diff options
context:
space:
mode:
authorAdam Copp <adamcopp@google.com>2012-10-05 16:38:07 +0100
committerAdam Copp <adamcopp@google.com>2012-10-05 16:38:07 +0100
commitfaa985bd481187ed6f569509f65e1f34a6e0b65e (patch)
treea027b3c04775b8247da7aa2824f25cd5fdc12b36 /photoviewer
parentda165c2e30ec1040419cded96a6248ccfe303a94 (diff)
downloadandroid_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.java6
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);