From 10ad04113b2f78ff5d1c46c5cde4cb35779a9ca8 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 10:22:13 +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=E4=B8=BA=E7=A9=BA=E4=BC=9A=E5=BC=95?= =?UTF-8?q?=E8=B5=B7=E7=A9=BA=E6=8C=87=E9=92=88=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- build.gradle | 2 +- .../lib/homhomlib/design/SlidingLayout.java | 48 ++++++++++--------- 3 files changed, 27 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index e279381..b2c1d43 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ allprojects{ mavenCentral() } } -implementation 'io.openharmony.tpc.thirdlib:SlidingLayout:1.0.1' +implementation 'io.openharmony.tpc.thirdlib:SlidingLayout:1.0.2' ``` diff --git a/build.gradle b/build.gradle index 025fdb0..643427f 100644 --- a/build.gradle +++ b/build.gradle @@ -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' } } diff --git a/library/src/main/java/lib/homhomlib/design/SlidingLayout.java b/library/src/main/java/lib/homhomlib/design/SlidingLayout.java index b0390e7..f77c141 100644 --- a/library/src/main/java/lib/homhomlib/design/SlidingLayout.java +++ b/library/src/main/java/lib/homhomlib/design/SlidingLayout.java @@ -91,31 +91,33 @@ public class SlidingLayout extends StackLayout implements ComponentContainer.Lay private void init(Context context, AttrSet attrs) { - boolean hasAttr; - hasAttr = attrs.getAttr(BACKGROUND_COMPONENT).isPresent(); - if (hasAttr) { - String layoutId = attrs.getAttr(BACKGROUND_COMPONENT).get().getStringValue(); - if (layoutId != null && layoutId.contains("$layout:")) { - layoutId = layoutId.replace("$layout:", ""); - try { - mBackgroundViewLayoutId = Integer.parseInt(layoutId); - } catch (NumberFormatException e) { - HiLog.error(new HiLogLabel(HiLog.ERROR, 0xD003A01, "LocalHiLog"), - "background component layoutId error"); + if (attrs != null) { + boolean hasAttr; + hasAttr = attrs.getAttr(BACKGROUND_COMPONENT).isPresent(); + if (hasAttr) { + String layoutId = attrs.getAttr(BACKGROUND_COMPONENT).get().getStringValue(); + if (layoutId != null && layoutId.contains("$layout:")) { + layoutId = layoutId.replace("$layout:", ""); + try { + mBackgroundViewLayoutId = Integer.parseInt(layoutId); + } catch (NumberFormatException e) { + HiLog.error(new HiLogLabel(HiLog.ERROR, 0xD003A01, "LocalHiLog"), + "background component layoutId error"); + } } } - } - hasAttr = attrs.getAttr(SLIDING_MODE).isPresent(); - if (hasAttr) { - mSlidingMode = attrs.getAttr(SLIDING_MODE).get().getIntegerValue(); - } - hasAttr = attrs.getAttr(TOP_MAX).isPresent(); - if (hasAttr) { - mSlidingTopMaxDistance = attrs.getAttr(TOP_MAX).get().getDimensionValue(); - } - if (mBackgroundViewLayoutId != 0) { - Component component = LayoutScatter.getInstance(context).parse(mBackgroundViewLayoutId, null, false); - setBackgroundComponent(component); + hasAttr = attrs.getAttr(SLIDING_MODE).isPresent(); + if (hasAttr) { + mSlidingMode = attrs.getAttr(SLIDING_MODE).get().getIntegerValue(); + } + hasAttr = attrs.getAttr(TOP_MAX).isPresent(); + if (hasAttr) { + mSlidingTopMaxDistance = attrs.getAttr(TOP_MAX).get().getDimensionValue(); + } + if (mBackgroundViewLayoutId != 0) { + Component component = LayoutScatter.getInstance(context).parse(mBackgroundViewLayoutId, null, false); + setBackgroundComponent(component); + } } mTouchSlop = 30; setDraggedListener(1, draggedListener); -- Gitee