diff --git a/README.md b/README.md index 2c9144a8ca9f8d92bfaeb9fac77debbd54b6a5fd..c94f53119bdab857e4ab08f613b10618341dec65 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 5ee77552ab5fc0fd3d7404b7baeddd2582d0fb95..6f2d9a6d7972cd2cdba8621487ec3953bcc9f7eb 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 af8a626a03877918151517bb1ac9f5e3b54dc367..cc5c2cdac6d34e29e8020873fc2d1eaaad9eec46 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' } }