From 440bdf2624b4d7fcbab1c86daac6ce2e6c301064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E8=B5=9B=E8=B5=9B?= <15868191030@163.com> Date: Tue, 6 Jul 2021 09:45:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E6=9E=84=E9=80=A0?= =?UTF-8?q?=E5=87=BD=E6=95=B0attrs=E5=8F=82=E6=95=B0=E4=B8=BA=E7=A9=BA?= =?UTF-8?q?=E6=97=B6=E4=BC=9A=E5=87=BA=E7=8E=B0=E7=A9=BA=E6=8C=87=E9=92=88?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- .../com/leaking/slideswitch/SlideSwitch.java | 26 ++++++++++--------- build.gradle | 4 +-- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 2c9144a..c94f531 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ allprojects{ mavenCentral() } } -implementation 'io.openharmony.tpc.thirdlib:SlideSwitch:1.0.2' +implementation 'io.openharmony.tpc.thirdlib:SlideSwitch:1.0.3' ``` diff --git a/SlideSwitch/src/main/java/com/leaking/slideswitch/SlideSwitch.java b/SlideSwitch/src/main/java/com/leaking/slideswitch/SlideSwitch.java index 5ee7755..6f2d9a6 100644 --- a/SlideSwitch/src/main/java/com/leaking/slideswitch/SlideSwitch.java +++ b/SlideSwitch/src/main/java/com/leaking/slideswitch/SlideSwitch.java @@ -101,18 +101,20 @@ public class SlideSwitch extends Component implements Component.DrawTask, Compon listener = null; paint = new Paint(); paint.setAntiAlias(true); - boolean hasAttr; - hasAttr = attrs.getAttr(THEME_COLOR).isPresent(); - if (hasAttr) { - color_theme = attrs.getAttr(THEME_COLOR).get().getIntegerValue(); - } - hasAttr = attrs.getAttr(IS_OPEN).isPresent(); - if (hasAttr) { - isOpen = attrs.getAttr(IS_OPEN).get().getBoolValue(); - } - hasAttr = attrs.getAttr(SHAPE).isPresent(); - if (hasAttr) { - shape = attrs.getAttr(SHAPE).get().getIntegerValue(); + if (attrs != null) { + boolean hasAttr; + hasAttr = attrs.getAttr(THEME_COLOR).isPresent(); + if (hasAttr) { + color_theme = attrs.getAttr(THEME_COLOR).get().getIntegerValue(); + } + hasAttr = attrs.getAttr(IS_OPEN).isPresent(); + if (hasAttr) { + isOpen = attrs.getAttr(IS_OPEN).get().getBoolValue(); + } + hasAttr = attrs.getAttr(SHAPE).isPresent(); + if (hasAttr) { + shape = attrs.getAttr(SHAPE).get().getIntegerValue(); + } } addDrawTask(this); setTouchEventListener(this); diff --git a/build.gradle b/build.gradle index af8a626..cc5c2cd 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ ohos { compatibleSdkVersion 5 } } - + buildscript { repositories { maven { @@ -19,7 +19,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.5' + classpath 'com.huawei.ohos:hap:2.4.2.7' classpath 'com.huawei.ohos:decctest:1.0.0.6' } } -- Gitee