summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2010-12-02 13:43:52 -0800
committerMichael Jurka <mikejurka@google.com>2010-12-02 13:44:08 -0800
commit8e414ee3cb67112f191304a9b10d63b28057d9f3 (patch)
tree774b5d57195800533c0739f227b3a986e56cc520 /src
parentc4ebd819711e85d0430fea0fe855fd56b4154840 (diff)
downloadandroid_packages_apps_Trebuchet-8e414ee3cb67112f191304a9b10d63b28057d9f3.tar.gz
android_packages_apps_Trebuchet-8e414ee3cb67112f191304a9b10d63b28057d9f3.tar.bz2
android_packages_apps_Trebuchet-8e414ee3cb67112f191304a9b10d63b28057d9f3.zip
Fixing crash in CacheableTextView
Not caching text view if the width/height of the text is 0
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/CacheableTextView.java36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/com/android/launcher2/CacheableTextView.java b/src/com/android/launcher2/CacheableTextView.java
index 084810eae..eba29ec0f 100644
--- a/src/com/android/launcher2/CacheableTextView.java
+++ b/src/com/android/launcher2/CacheableTextView.java
@@ -90,22 +90,26 @@ public class CacheableTextView extends TextView {
Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) + hPadding;
final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV + vPadding;
- mCache = Bitmap.createBitmap((int) (textCacheRight - mTextCacheLeft),
- (int) (textCacheBottom - mTextCacheTop), Config.ARGB_8888);
- mCacheCanvas.setBitmap(mCache);
- mCacheCanvas.translate(-mTextCacheLeft, -mTextCacheTop);
-
- mIsBuildingCache = true;
- setAlpha(1.0f);
- draw(mCacheCanvas);
- setAlpha(prevAlpha);
- mIsBuildingCache = false;
-
- // A hack-- we set the text to be one space (we don't make it empty just to avoid any
- // potential issues with text measurement, like line height, etc.) so that the text view
- // doesn't draw it anymore, since it's been cached. We have to manually rebuild
- // the cache whenever the text is changed (which is never in Launcher)
- setText(" ");
+ int width = (int) (textCacheRight - mTextCacheLeft);
+ int height = (int) (textCacheBottom - mTextCacheTop);
+
+ if (width != 0 && height != 0) {
+ mCache = Bitmap.createBitmap(width, height, Config.ARGB_8888);
+ mCacheCanvas.setBitmap(mCache);
+ mCacheCanvas.translate(-mTextCacheLeft, -mTextCacheTop);
+
+ mIsBuildingCache = true;
+ setAlpha(1.0f);
+ draw(mCacheCanvas);
+ setAlpha(prevAlpha);
+ mIsBuildingCache = false;
+
+ // A hack-- we set the text to be one space (we don't make it empty just to avoid any
+ // potential issues with text measurement, like line height, etc.) so that the text view
+ // doesn't draw it anymore, since it's been cached. We have to manually rebuild
+ // the cache whenever the text is changed (which is never in Launcher)
+ setText(" ");
+ }
}
public void draw(Canvas canvas) {