diff options
author | Patrick Dubroy <dubroy@google.com> | 2011-03-09 16:25:11 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2011-03-09 16:25:11 -0800 |
commit | c3579bc065526fe4b68d03498977f700e52365e3 (patch) | |
tree | 9e53369901971246025c286e02f8c0236153d2d7 | |
parent | 461275d399412af4c6dd8ade1463281c91614a85 (diff) | |
parent | a017c0379c30e0272a88a93d05b6a30e28955b88 (diff) | |
download | android_packages_apps_Trebuchet-c3579bc065526fe4b68d03498977f700e52365e3.tar.gz android_packages_apps_Trebuchet-c3579bc065526fe4b68d03498977f700e52365e3.tar.bz2 android_packages_apps_Trebuchet-c3579bc065526fe4b68d03498977f700e52365e3.zip |
am a017c037: Fix 3306005: NPE at android.widget.TextView.getExtendedPaddingTop()
* commit 'a017c0379c30e0272a88a93d05b6a30e28955b88':
Fix 3306005: NPE at android.widget.TextView.getExtendedPaddingTop()
-rw-r--r-- | src/com/android/launcher2/BubbleTextView.java | 23 |
1 files changed, 20 insertions, 3 deletions
diff --git a/src/com/android/launcher2/BubbleTextView.java b/src/com/android/launcher2/BubbleTextView.java index f708e2fda..a8db330b3 100644 --- a/src/com/android/launcher2/BubbleTextView.java +++ b/src/com/android/launcher2/BubbleTextView.java @@ -152,8 +152,14 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca mPressedOrFocusedBackground = null; } if (isFocused()) { - mPressedOrFocusedBackground = createGlowingOutline( - mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor); + if (mLayout == null) { + // In some cases, we get focus before we have been layed out. Set the + // background to null so that it will get created when the view is drawn. + mPressedOrFocusedBackground = null; + } else { + mPressedOrFocusedBackground = createGlowingOutline( + mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor); + } mStayPressed = false; invalidatePressedOrFocusedBackground(); } @@ -190,7 +196,7 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca destCanvas.save(); destCanvas.translate(-getScrollX() + padding / 2, -getScrollY() + padding / 2); destCanvas.clipRect(clipRect, Op.REPLACE); - draw(destCanvas); + drawImpl(destCanvas, true); destCanvas.restore(); } @@ -265,8 +271,19 @@ public class BubbleTextView extends TextView implements VisibilityChangedBroadca } invalidatePressedOrFocusedBackground(); } + @Override public void draw(Canvas canvas) { + drawImpl(canvas, false); + } + + private void drawImpl(Canvas canvas, boolean preventRecursion) { + // If the View is focused but the focused background hasn't been created yet, create it now + if (!preventRecursion && isFocused() && mPressedOrFocusedBackground == null) { + mPressedOrFocusedBackground = createGlowingOutline( + mTempCanvas, mFocusedGlowColor, mFocusedOutlineColor); + } + if (mPressedOrFocusedBackground != null && (isPressed() || isFocused() || mStayPressed)) { // The blue glow can extend outside of our clip region, so we first temporarily expand // the canvas's clip region |