Fix NPE at boot.
This commit is contained in:
@ -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;
|
||||
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 += 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 += (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.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);
|
||||
scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2;
|
||||
scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom);
|
||||
}
|
||||
}
|
||||
|
||||
invalidate(dirty.left + scrollX, dirty.top + scrollY,
|
||||
|
Reference in New Issue
Block a user