diff options
author | John Reck <jreck@google.com> | 2011-10-31 17:18:50 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-10-31 17:18:50 -0700 |
commit | 36b2aac54e5a9f90addf8092c7b5358822d2b1c4 (patch) | |
tree | f1a2d6ef3a55f1e6ae9309cb85c1b530592dbbdb | |
parent | fd02f6d47c75e37f4eff80e823a0d9c7c10f6c08 (diff) | |
parent | a98c83b24d2459e3af2b251facec446199190a4e (diff) | |
download | packages_apps_Browser-36b2aac54e5a9f90addf8092c7b5358822d2b1c4.zip packages_apps_Browser-36b2aac54e5a9f90addf8092c7b5358822d2b1c4.tar.gz packages_apps_Browser-36b2aac54e5a9f90addf8092c7b5358822d2b1c4.tar.bz2 |
Merge "Monkey proofing" into ics-mr1
-rw-r--r-- | src/com/android/browser/PhoneUi.java | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/com/android/browser/PhoneUi.java b/src/com/android/browser/PhoneUi.java index ffcaaf8..a13eca3 100644 --- a/src/com/android/browser/PhoneUi.java +++ b/src/com/android/browser/PhoneUi.java @@ -529,12 +529,14 @@ public class PhoneUi extends BaseUi { if (mTitleBarBitmap == null || mTitleBarBitmap.getWidth() != tbar.getWidth() || mTitleBarBitmap.getHeight() != tbar.getEmbeddedHeight()) { - mTitleBarBitmap = Bitmap.createBitmap(tbar.getWidth(), - tbar.getEmbeddedHeight(), Bitmap.Config.RGB_565); + mTitleBarBitmap = safeCreateBitmap(tbar.getWidth(), + tbar.getEmbeddedHeight()); + } + if (mTitleBarBitmap != null) { + Canvas c = new Canvas(mTitleBarBitmap); + tbar.draw(c); + c.setBitmap(null); } - Canvas c = new Canvas(mTitleBarBitmap); - tbar.draw(c); - c.setBitmap(null); } else { mTitleBarBitmap = null; } @@ -544,18 +546,28 @@ public class PhoneUi extends BaseUi { if (mContentBitmap == null || mContentBitmap.getWidth() != web.getWidth() || mContentBitmap.getHeight() != h) { - mContentBitmap = Bitmap.createBitmap(web.getWidth(), h, - Bitmap.Config.RGB_565); + mContentBitmap = safeCreateBitmap(web.getWidth(), h); + } + if (mContentBitmap != null) { + Canvas c = new Canvas(mContentBitmap); + int tx = web.getScrollX(); + int ty = web.getScrollY(); + c.translate(-tx, -ty - tbar.getEmbeddedHeight()); + web.draw(c); + c.setBitmap(null); } - Canvas c = new Canvas(mContentBitmap); - int tx = web.getScrollX(); - int ty = web.getScrollY(); - c.translate(-tx, -ty - tbar.getEmbeddedHeight()); - web.draw(c); - c.setBitmap(null); mContent.setImageBitmap(mContentBitmap); } + private Bitmap safeCreateBitmap(int width, int height) { + if (width <= 0 || height <= 0) { + Log.w(LOGTAG, "safeCreateBitmap failed! width: " + width + + ", height: " + height); + return null; + } + return Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565); + } + public void set(Bitmap image) { mTitle.setVisibility(View.GONE); mContent.setImageBitmap(image); |