diff options
author | Tony Wickham <twickham@google.com> | 2015-11-18 19:51:55 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-11-18 19:51:55 +0000 |
commit | 0151ff168368883301e84c7d1f790c9f2721e459 (patch) | |
tree | 8f19dd380e38f2dc6d133572702fbd46dc387711 | |
parent | b9c29d455e301d1b31b911a37eb3bec7e0e16865 (diff) | |
parent | f2bd93c7e0705fae1a94f95356702ab735f19e28 (diff) | |
download | android_packages_apps_Trebuchet-0151ff168368883301e84c7d1f790c9f2721e459.tar.gz android_packages_apps_Trebuchet-0151ff168368883301e84c7d1f790c9f2721e459.tar.bz2 android_packages_apps_Trebuchet-0151ff168368883301e84c7d1f790c9f2721e459.zip |
Merge "Handle errors gracefully in WallpaperCropActivity." into ub-launcher3-burnaby-polish
-rw-r--r-- | WallpaperPicker/src/com/android/photos/BitmapRegionTileSource.java | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/WallpaperPicker/src/com/android/photos/BitmapRegionTileSource.java b/WallpaperPicker/src/com/android/photos/BitmapRegionTileSource.java index 2d496a5a6..6baac6a6b 100644 --- a/WallpaperPicker/src/com/android/photos/BitmapRegionTileSource.java +++ b/WallpaperPicker/src/com/android/photos/BitmapRegionTileSource.java @@ -159,6 +159,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource { public enum State { NOT_LOADED, LOADED, ERROR_LOADING }; private State mState = State.NOT_LOADED; + /** Returns whether loading was successful. */ public boolean loadInBackground(InBitmapProvider bitmapProvider) { ExifInterface ei = new ExifInterface(); if (readExif(ei)) { @@ -193,7 +194,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource { try { mPreview = loadPreviewBitmap(opts); } catch (IllegalArgumentException e) { - Log.d(TAG, "Unable to reusage bitmap", e); + Log.d(TAG, "Unable to reuse bitmap", e); opts.inBitmap = null; mPreview = null; } @@ -202,6 +203,10 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource { if (mPreview == null) { mPreview = loadPreviewBitmap(opts); } + if (mPreview == null) { + mState = State.ERROR_LOADING; + return false; + } // Verify that the bitmap can be used on GL surface try { @@ -212,7 +217,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource { Log.d(TAG, "Image cannot be rendered on a GL surface", e); mState = State.ERROR_LOADING; } - return true; + return mState == State.LOADED; } } @@ -310,7 +315,7 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource { Bitmap b = BitmapFactory.decodeStream(is, null, options); Utils.closeSilently(is); return b; - } catch (FileNotFoundException e) { + } catch (FileNotFoundException | OutOfMemoryError e) { Log.e("BitmapRegionTileSource", "Failed to load URI " + mUri, e); return null; } @@ -412,7 +417,8 @@ public class BitmapRegionTileSource implements TiledImageRenderer.TileSource { "Failed to create preview of apropriate size! " + " in: %dx%d, out: %dx%d", mWidth, mHeight, - preview.getWidth(), preview.getHeight())); + preview == null ? -1 : preview.getWidth(), + preview == null ? -1 : preview.getHeight())); } } } |