From d44661c6100331ae26df7d1896a48d1999b091f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=90=B4=E6=B3=A2?= <349637011@qq.com> Date: Fri, 26 Feb 2021 08:31:06 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A2=9C=E8=89=B2=E6=B7=BB=E5=8A=A00=E5=88=A4?= =?UTF-8?q?=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/widget/switcher/XSwitchButton.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java b/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java index 0ab2246..e0a81ca 100644 --- a/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java +++ b/widget/src/main/java/com/pichs/common/widget/switcher/XSwitchButton.java @@ -1060,17 +1060,23 @@ public void setBackgroundColor(int offColor, int onColor) { } public void setThumbColor(int thumbColor, int thumbCheckedColor, int thumbPressedColor, int thumbUnEnabledColor) { - this.thumbColor = thumbColor; - this.thumbPressedColor = thumbPressedColor; - this.thumbCheckedColor = thumbCheckedColor; - this.thumbUnEnabledColor = thumbUnEnabledColor; - thumbColorStateList = new XGradientHelper.ColorStateListBuilder() - .setUnSateColor(thumbColor) + if (thumbColor > 0) { + this.thumbColor = thumbColor; + } + if (thumbPressedColor > 0) { + this.thumbPressedColor = thumbPressedColor; + } + if (thumbCheckedColor > 0) { + this.thumbCheckedColor = thumbCheckedColor; + } + if (thumbUnEnabledColor > 0) { + this.thumbUnEnabledColor = thumbUnEnabledColor; + } + thumbColorStateList = new XGradientHelper.ColorStateListBuilder().setUnSateColor(thumbColor) .addPressedColor(thumbPressedColor) .addCheckedColor(thumbCheckedColor) .addUnEnabledColor(thumbUnEnabledColor) .build(); -// mCurrThumbColor = thumbColorStateList.getDefaultColor(); invalidate(); } } \ No newline at end of file