diff options
author | Michael Jurka <mikejurka@google.com> | 2010-11-17 12:33:46 -0800 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2010-12-01 16:01:02 -0800 |
commit | 67b2f6cba5aa7b5d0fac5e66ba8f3d5f887baee6 (patch) | |
tree | bdfdbf4d526dc347ba002e8fb867fbe4cbd8cf28 /src/com/android/launcher2/BubbleTextView.java | |
parent | 49767aefe5b32d523ba1e43696f8adafa64a778f (diff) | |
download | android_packages_apps_Trebuchet-67b2f6cba5aa7b5d0fac5e66ba8f3d5f887baee6.tar.gz android_packages_apps_Trebuchet-67b2f6cba5aa7b5d0fac5e66ba8f3d5f887baee6.tar.bz2 android_packages_apps_Trebuchet-67b2f6cba5aa7b5d0fac5e66ba8f3d5f887baee6.zip |
Caching icon labels to bitmaps for better performance
Change-Id: I78a3c116c1103b5b994a47f2cfcff18c0a9b31b8
Diffstat (limited to 'src/com/android/launcher2/BubbleTextView.java')
-rw-r--r-- | src/com/android/launcher2/BubbleTextView.java | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index f4a3d4499..603930792 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -19,6 +19,7 @@ package com.android.launcher2; import android.widget.TextView; import android.content.Context; import android.util.AttributeSet; +import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.graphics.RectF; @@ -32,7 +33,7 @@ import com.android.launcher.R; * because we want to make the bubble taller than the text and TextView's clip is * too aggressive. */ -public class BubbleTextView extends TextView { +public class BubbleTextView extends CacheableTextView { static final float CORNER_RADIUS = 8.0f; static final float PADDING_H = 5.0f; static final float PADDING_V = 1.0f; @@ -77,6 +78,18 @@ public class BubbleTextView extends TextView { mPaddingV = PADDING_V * scale; } + public void applyFromShortcutInfo(ShortcutInfo info, IconCache iconCache) { + Bitmap b = info.getIcon(iconCache); + + setCompoundDrawablesWithIntrinsicBounds(null, + new FastBitmapDrawable(b), + null, null); + setText(info.title); + buildAndEnableCache(); + setTag(info); + + } + @Override protected boolean setFrame(int left, int top, int right, int bottom) { if (mLeft != left || mRight != right || mTop != top || mBottom != bottom) { @@ -129,7 +142,9 @@ public class BubbleTextView extends TextView { top + layout.getLineTop(0) - mPaddingV, Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft), top + layout.getLineBottom(0) + mPaddingV); - canvas.drawRoundRect(rect, mCornerRadius, mCornerRadius, mPaint); + // TEMPORARILY DISABLE DRAWING ROUND RECT -- re-enable this when we tweak CacheableTextView + // to support padding so we can capture the "rounded" edges + //canvas.drawRoundRect(rect, mCornerRadius, mCornerRadius, mPaint); super.draw(canvas); } |