diff options
author | Michael Jurka <mikejurka@google.com> | 2011-01-12 11:59:23 -0800 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2011-01-12 13:49:37 -0800 |
commit | c9c548eb1093be6106279a792df5ba8bb36b6326 (patch) | |
tree | 0966b628c5a93afad340be8c467ad6dc6b25de45 /src | |
parent | f5675decc9f0e5b83a7041d6181343abe2cfe31c (diff) | |
download | android_packages_apps_Trebuchet-c9c548eb1093be6106279a792df5ba8bb36b6326.tar.gz android_packages_apps_Trebuchet-c9c548eb1093be6106279a792df5ba8bb36b6326.tar.bz2 android_packages_apps_Trebuchet-c9c548eb1093be6106279a792df5ba8bb36b6326.zip |
Potential fix for garbled text in All Apps
- now redrawing the cache for CacheableTextView every time setText is called
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/launcher2/BubbleTextView.java | 1 | ||||
-rw-r--r-- | src/com/android/launcher2/CacheableTextView.java | 28 | ||||
-rw-r--r-- | src/com/android/launcher2/PagedViewIcon.java | 2 |
3 files changed, 10 insertions, 21 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index 4d1dbf88c..9f0e5fb98 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -118,7 +118,6 @@ public class BubbleTextView extends CacheableTextView implements VisibilityChang new FastBitmapDrawable(b), null, null); setText(info.title); - buildAndEnableCache(); setTag(info); } diff --git a/src/com/android/launcher2/CacheableTextView.java b/src/com/android/launcher2/CacheableTextView.java index da2f302c1..167133da0 100644 --- a/src/com/android/launcher2/CacheableTextView.java +++ b/src/com/android/launcher2/CacheableTextView.java @@ -18,10 +18,9 @@ package com.android.launcher2; import android.content.Context; import android.graphics.Bitmap; -import android.graphics.Bitmap.Config; import android.graphics.Canvas; -import android.graphics.Color; import android.graphics.Paint; +import android.graphics.Bitmap.Config; import android.text.Layout; import android.util.AttributeSet; import android.widget.TextView; @@ -39,7 +38,7 @@ public class CacheableTextView extends TextView { private int mPrevAlpha = -1; private boolean mIsBuildingCache; - boolean mWaitingToGenerateCache; + boolean mIsTextCacheDirty; float mTextCacheLeft; float mTextCacheTop; float mTextCacheScrollX; @@ -73,18 +72,12 @@ public class CacheableTextView extends TextView { return 0; } - public void buildAndEnableCache() { - // Defers building the cache until the next draw to allow measuring - // and laying out. - buildAndEnableCache(false); + public void setText(CharSequence text, BufferType type) { + super.setText(text, type); + mIsTextCacheDirty = true; } - public void buildAndEnableCache(boolean isImmediate) { - if (getLayout() == null || !isImmediate) { - mWaitingToGenerateCache = true; - return; - } - + private void buildAndUpdateCache() { final Layout layout = getLayout(); final int left = getCompoundPaddingLeft(); final int top = getExtendedPaddingTop(); @@ -133,8 +126,7 @@ public class CacheableTextView extends TextView { // 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) + // doesn't draw it anymore, since it's been cached. mText = getText(); setText(" "); } @@ -145,9 +137,9 @@ public class CacheableTextView extends TextView { } public void draw(Canvas canvas) { - if (mWaitingToGenerateCache && !mIsBuildingCache) { - buildAndEnableCache(true); - mWaitingToGenerateCache = false; + if (mIsTextCacheDirty && !mIsBuildingCache) { + buildAndUpdateCache(); + mIsTextCacheDirty = false; } if (mCache != null && !mIsBuildingCache) { canvas.drawBitmap(mCache, mTextCacheLeft - mTextCacheScrollX + mScrollX, diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java index 6ce308b1d..90cff97d6 100644 --- a/src/com/android/launcher2/PagedViewIcon.java +++ b/src/com/android/launcher2/PagedViewIcon.java @@ -143,7 +143,6 @@ public class PagedViewIcon extends CacheableTextView implements Checkable { mIcon = info.iconBitmap; setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null); setText(info.title); - buildAndEnableCache(); setTag(info); if (createHolographicOutlines) { @@ -160,7 +159,6 @@ public class PagedViewIcon extends CacheableTextView implements Checkable { modelIconCache.getFullResIcon(info, packageManager), mContext); setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null); setText(info.loadLabel(packageManager)); - buildAndEnableCache(); setTag(info); if (createHolographicOutlines) { |