diff --git a/README.md b/README.md index e27938188b3642c98e8ea3c8c46c4674bf0b5a84..b2c1d4311a0eb737da7dff011934754d27ca98e7 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 025fdb0d894e04deda83f88f05a8574e5d04a65b..643427fc88ddfe3d7337dacf1d54d5bea150bc3b 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 b0390e79ca5b6b1b210650be8088d6ecd44e0f57..f77c141a54f296fbb97f9ab8cacecb2d2dceb165 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);