Skip to content

Commit be06e32

Browse files
author
Fabrice Di Meglio
committed
Fix bug #7148393 Switch can crash when hierarchyviewer is connected
Change-Id: I1713138a60358cc76f6cf373082a94199e85c717
1 parent e11dc0d commit be06e32

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)