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
|
// for each compound drawable in onDraw(). Make sure to update each section
|
||||||
// accordingly.
|
// accordingly.
|
||||||
final TextView.Drawables drawables = mDrawables;
|
final TextView.Drawables drawables = mDrawables;
|
||||||
if (drawable == drawables.mDrawableLeft) {
|
if (drawables != null) {
|
||||||
final int compoundPaddingTop = getCompoundPaddingTop();
|
if (drawable == drawables.mDrawableLeft) {
|
||||||
final int compoundPaddingBottom = getCompoundPaddingBottom();
|
final int compoundPaddingTop = getCompoundPaddingTop();
|
||||||
final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop;
|
final int compoundPaddingBottom = getCompoundPaddingBottom();
|
||||||
|
final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop;
|
||||||
|
|
||||||
scrollX += mPaddingLeft;
|
scrollX += mPaddingLeft;
|
||||||
scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightLeft) / 2;
|
scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightLeft) / 2;
|
||||||
} else if (drawable == drawables.mDrawableRight) {
|
} else if (drawable == drawables.mDrawableRight) {
|
||||||
final int compoundPaddingTop = getCompoundPaddingTop();
|
final int compoundPaddingTop = getCompoundPaddingTop();
|
||||||
final int compoundPaddingBottom = getCompoundPaddingBottom();
|
final int compoundPaddingBottom = getCompoundPaddingBottom();
|
||||||
final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop;
|
final int vspace = mBottom - mTop - compoundPaddingBottom - compoundPaddingTop;
|
||||||
|
|
||||||
scrollX += (mRight - mLeft - mPaddingRight - drawables.mDrawableSizeRight);
|
scrollX += (mRight - mLeft - mPaddingRight - drawables.mDrawableSizeRight);
|
||||||
scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightRight) / 2;
|
scrollY += compoundPaddingTop + (vspace - drawables.mDrawableHeightRight) / 2;
|
||||||
} else if (drawable == drawables.mDrawableTop) {
|
} else if (drawable == drawables.mDrawableTop) {
|
||||||
final int compoundPaddingLeft = getCompoundPaddingLeft();
|
final int compoundPaddingLeft = getCompoundPaddingLeft();
|
||||||
final int compoundPaddingRight = getCompoundPaddingRight();
|
final int compoundPaddingRight = getCompoundPaddingRight();
|
||||||
final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft;
|
final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft;
|
||||||
|
|
||||||
scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthTop) / 2;
|
scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthTop) / 2;
|
||||||
scrollY += mPaddingTop;
|
scrollY += mPaddingTop;
|
||||||
} else if (drawable == drawables.mDrawableBottom) {
|
} else if (drawable == drawables.mDrawableBottom) {
|
||||||
final int compoundPaddingLeft = getCompoundPaddingLeft();
|
final int compoundPaddingLeft = getCompoundPaddingLeft();
|
||||||
final int compoundPaddingRight = getCompoundPaddingRight();
|
final int compoundPaddingRight = getCompoundPaddingRight();
|
||||||
final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft;
|
final int hspace = mRight - mLeft - compoundPaddingRight - compoundPaddingLeft;
|
||||||
|
|
||||||
scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2;
|
scrollX += compoundPaddingLeft + (hspace - drawables.mDrawableWidthBottom) / 2;
|
||||||
scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom);
|
scrollY += (mBottom - mTop - mPaddingBottom - drawables.mDrawableSizeBottom);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
invalidate(dirty.left + scrollX, dirty.top + scrollY,
|
invalidate(dirty.left + scrollX, dirty.top + scrollY,
|
||||||
|
|||||||
Reference in New Issue
Block a user