diff options
author | Romain Guy <romainguy@android.com> | 2009-05-20 15:09:21 -0700 |
---|---|---|
committer | Romain Guy <romainguy@android.com> | 2009-05-20 15:09:21 -0700 |
commit | a6cd4e03e6bde0c4b76ad7290eb2c527398478d1 (patch) | |
tree | 116963bb1b0ffe76105a86153f117a2ec199acff /core/java/android/widget/TextView.java | |
parent | fe0daa7da8608fd83c580ee62240463b5b84afde (diff) | |
download | frameworks_base-a6cd4e03e6bde0c4b76ad7290eb2c527398478d1.zip frameworks_base-a6cd4e03e6bde0c4b76ad7290eb2c527398478d1.tar.gz frameworks_base-a6cd4e03e6bde0c4b76ad7290eb2c527398478d1.tar.bz2 |
Fix NPE at boot.
Diffstat (limited to 'core/java/android/widget/TextView.java')
-rw-r--r-- | core/java/android/widget/TextView.java | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b7fbc0e..40a72a4 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -3711,34 +3711,36 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener // for each compound drawable in onDraw(). Make sure to update each section // accordingly. final TextView.Drawables drawables = mDrawables; - if (drawable == drawables.mDrawableLeft) { - final int compoundPaddingTop = getCompoundPaddingTop(); - final int compoundPaddingBottom = getCompoundPaddingBottom(); - final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; - - scrollX += mPaddingLeft; - scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightLeft) / 2; - } else if (drawable == drawables.mDrawableRight) { - final int compoundPaddingTop = getCompoundPaddingTop(); - final int compoundPaddingBottom = getCompoundPaddingBottom(); - final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; - - scrollX += (mRight - mLeft - mPaddingRight - drawables.mDrawableSizeRight); - scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightRight) / 2; - } else if (drawable == drawables.mDrawableTop) { - final int compoundPaddingLeft = getCompoundPaddingLeft(); - final int compoundPaddingRight = getCompoundPaddingRight(); - final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; - - scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthTop) / 2; - scrollY += mPaddingTop; - } else if (drawable == drawables.mDrawableBottom) { - final int compoundPaddingLeft = getCompoundPaddingLeft(); - final int compoundPaddingRight = getCompoundPaddingRight(); - final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; - - scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2; - scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom); + if (drawables != null) { + if (drawable == drawables.mDrawableLeft) { + final int compoundPaddingTop = getCompoundPaddingTop(); + final int compoundPaddingBottom = getCompoundPaddingBottom(); + final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; + + scrollX += mPaddingLeft; + scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightLeft) / 2; + } else if (drawable == drawables.mDrawableRight) { + final int compoundPaddingTop = getCompoundPaddingTop(); + final int compoundPaddingBottom = getCompoundPaddingBottom(); + final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop; + + scrollX += (mRight - mLeft - mPaddingRight - drawables.mDrawableSizeRight); + scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightRight) / 2; + } else if (drawable == drawables.mDrawableTop) { + final int compoundPaddingLeft = getCompoundPaddingLeft(); + final int compoundPaddingRight = getCompoundPaddingRight(); + final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; + + scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthTop) / 2; + scrollY += mPaddingTop; + } else if (drawable == drawables.mDrawableBottom) { + final int compoundPaddingLeft = getCompoundPaddingLeft(); + final int compoundPaddingRight = getCompoundPaddingRight(); + final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft; + + scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2; + scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom); + } } invalidate(dirty.left + scrollX, dirty.top + scrollY, |