Skip to content

Commit 8872465

Browse files
Fabrice Di MeglioAndroid (Google) Code Review
authored andcommitted
Merge "Fix bug #7148393 Switch can crash when hierarchyviewer is connected" into jb-mr1-dev
2 parents b967464 + be06e32 commit 8872465

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

core/java/android/widget/Switch.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -750,10 +750,11 @@ protected void onDraw(Canvas canvas) {
750750
mTextPaint.drawableState = getDrawableState();
751751

752752
Layout switchText = getTargetCheckedState() ? mOnLayout : mOffLayout;
753-
754-
canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2,
755-
(switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
756-
switchText.draw(canvas);
753+
if (switchText != null) {
754+
canvas.translate((thumbLeft + thumbRight) / 2 - switchText.getWidth() / 2,
755+
(switchInnerTop + switchInnerBottom) / 2 - switchText.getHeight() / 2);
756+
switchText.draw(canvas);
757+
}
757758

758759
canvas.restore();
759760
}

0 commit comments

Comments
 (0)