am 88724657: Merge "Fix bug #7148393 Switch can crash when hierarchyviewer is connected" into jb-mr1-dev

* commit '8872465709d336083a908cb79d08661c6658265b':
  Fix bug #7148393 Switch can crash when hierarchyviewer is connected
This commit is contained in:
Fabrice Di Meglio
2012-09-12 13:29:27 -07:00
committed by Android Git Automerger

View File

@@ -750,10 +750,11 @@ public class Switch extends CompoundButton {
mTextPaint.drawableState = getDrawableState();
Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2,
(switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
switchText.draw(canvas);
if (switchText != null) {
canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2,
(switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
switchText.draw(canvas);
}
canvas.restore();
}