From 24b54d34a3d7c95683f68b45c3cfca6e353be3a9 Mon Sep 17 00:00:00 2001 From: JiangJun <2680104782@qq.com> Date: Fri, 20 Aug 2021 11:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E5=86=85=E5=AE=B9?= =?UTF-8?q?=E3=80=91=EF=BC=9Atoast=20codecheck?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 5 ++-- README.md | 4 ++- build.gradle | 3 ++ .../slice/MainAbilitySlice.java | 28 +++++++++++-------- .../swipestacksample/snackbar/SnackBar.java | 4 +++ .../util/TinderDirectionalCard.java | 10 +++++++ .../main/resources/base/element/string.json | 4 +-- library/proguard-rules.pro | 18 +----------- .../link/fls/swipestack/BaseSwipeCard.java | 7 +++++ .../fls/swipestack/SwipeDirectionalView.java | 10 +++---- 10 files changed, 54 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd968a..70246f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ +## 0.0.2-SNAPSHOT +- ohos 第二个版本,完整实现了原库的全部 api,提示信息优化 + ## 0.0.1-SNAPSHOT - ohos 第一个版本,完整实现了原库的全部 api - - diff --git a/README.md b/README.md index b34d2fa..520771c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ #### 效果演示 ![输入图片说明](https://images.gitee.com/uploads/images/2021/0817/144309_498e5273_5356950.gif "3.gif") + #### 安装教程 1.在项目根目录下的build.gradle文件中, @@ -30,7 +31,7 @@ allprojects { ```gradle dependencies { - implementation('com.gitee.chinasoft_ohos:SwipeStack:0.0.1-SNAPSHOT') + implementation('com.gitee.chinasoft_ohos:SwipeStack:0.0.2-SNAPSHOT') ...... } ``` @@ -76,6 +77,7 @@ CloudTest代码测试无异常 当前版本demo功能与原组件基本无差异 ## 版本迭代 +- 0.0.2-SNAPSHOT - 0.0.1-SNAPSHOT ## 版权和许可信息 diff --git a/build.gradle b/build.gradle index 49bd550..2768865 100644 --- a/build.gradle +++ b/build.gradle @@ -32,5 +32,8 @@ allprojects { maven { url 'https://developer.huawei.com/repo/' } + maven { + url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' + } } } diff --git a/entry/src/main/java/link/fls/swipestacksample/slice/MainAbilitySlice.java b/entry/src/main/java/link/fls/swipestacksample/slice/MainAbilitySlice.java index 1e80947..da226dc 100644 --- a/entry/src/main/java/link/fls/swipestacksample/slice/MainAbilitySlice.java +++ b/entry/src/main/java/link/fls/swipestacksample/slice/MainAbilitySlice.java @@ -159,25 +159,29 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL } @Override - public void onViewSwipedToLeft(int position) { + public void onViewSwipedToLeft(int position, String text) { itemAllNum++; - if (itemAllNum <= 6) { - toast("Test " + getString(ResourceTable.String_view_swiped_left, position)); - } else { - toast("Fab Test swiped to left "); + if (isViewSwipedToLeft) { + if (!text.contains("Fab")) { + toast(text + getString(ResourceTable.String_view_swiped_left)); + } else { + toast("Fab Test swiped to left "); + } + isViewSwipedToLeft = false; } - isViewSwipedToLeft = false; } @Override - public void onViewSwipedToRight(int position) { + public void onViewSwipedToRight(int position, String text) { itemAllNum++; - if (itemAllNum <= 6) { - toast("Test " + getString(ResourceTable.String_view_swiped_right, position)); - } else { - toast("Fab Test swiped to right"); + if (isViewSwipedToRight) { + if (!text.contains("Fab")) { + toast(text + getString(ResourceTable.String_view_swiped_right)); + } else { + toast("Fab Test swiped to right"); + } + isViewSwipedToRight = false; } - isViewSwipedToRight = false; } /** diff --git a/entry/src/main/java/link/fls/swipestacksample/snackbar/SnackBar.java b/entry/src/main/java/link/fls/swipestacksample/snackbar/SnackBar.java index 3f81e91..b5e2c7b 100644 --- a/entry/src/main/java/link/fls/swipestacksample/snackbar/SnackBar.java +++ b/entry/src/main/java/link/fls/swipestacksample/snackbar/SnackBar.java @@ -174,6 +174,8 @@ public class SnackBar { * * @param messageId the resource id of the string to display * @return this builder + * @throws NotExistException + * @throws WrongTypeException * @throws IOException */ public Builder withMessageId(int messageId) throws NotExistException, WrongTypeException, IOException { @@ -197,6 +199,8 @@ public class SnackBar { * * @param actionMessageResId the resource id of the string to display * @return this builder + * @throws NotExistException + * @throws WrongTypeException * @throws IOException */ public Builder withActionMessageId(int actionMessageResId) throws NotExistException, WrongTypeException, IOException { diff --git a/entry/src/main/java/link/fls/swipestacksample/util/TinderDirectionalCard.java b/entry/src/main/java/link/fls/swipestacksample/util/TinderDirectionalCard.java index ebb7baf..e0a1a31 100644 --- a/entry/src/main/java/link/fls/swipestacksample/util/TinderDirectionalCard.java +++ b/entry/src/main/java/link/fls/swipestacksample/util/TinderDirectionalCard.java @@ -47,6 +47,16 @@ public class TinderDirectionalCard extends BaseSwipeCard { reject.setVisibility(HIDE); } + /** + * 获取中央显示文字 + * + * @return 文字内容 + */ + @Override + public String getText() { + return nameText.getText(); + } + /** * 构造函数 * diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index 9d373f1..4f2e24b 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -26,11 +26,11 @@ }, { "name": "view_swiped_left", - "value": "%1$s swiped to left!" + "value": " swiped to left!" }, { "name": "view_swiped_right", - "value": "%1$s swiped to right!" + "value": " swiped to right!" }, { "name": "dummy_text", diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro index bc8414f..f7666e4 100644 --- a/library/proguard-rules.pro +++ b/library/proguard-rules.pro @@ -1,17 +1 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in /Users/frederikschweiger/Library/Android/sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} +# config module specific ProGuard rules here. \ No newline at end of file diff --git a/library/src/main/java/link/fls/swipestack/BaseSwipeCard.java b/library/src/main/java/link/fls/swipestack/BaseSwipeCard.java index cb7e498..5aba804 100644 --- a/library/src/main/java/link/fls/swipestack/BaseSwipeCard.java +++ b/library/src/main/java/link/fls/swipestack/BaseSwipeCard.java @@ -40,6 +40,13 @@ public abstract class BaseSwipeCard extends StackLayout { */ public abstract void hideAllTips(); + /** + * 获取中央显示文字 + * + * @return 文字内容 + */ + public abstract String getText(); + /** * 构造函数 * diff --git a/library/src/main/java/link/fls/swipestack/SwipeDirectionalView.java b/library/src/main/java/link/fls/swipestack/SwipeDirectionalView.java index 9628c90..3c1074e 100644 --- a/library/src/main/java/link/fls/swipestack/SwipeDirectionalView.java +++ b/library/src/main/java/link/fls/swipestack/SwipeDirectionalView.java @@ -142,7 +142,6 @@ public class SwipeDirectionalView extends StackLayout implements ICardState { if (componentList.indexOf(component) == 0) { setTouchComponent(component); } - } itemAllNum = componentList.size() + 1; return this; @@ -201,7 +200,7 @@ public class SwipeDirectionalView extends StackLayout implements ICardState { if (component instanceof BaseSwipeCard) { ((BaseSwipeCard) component).showAccept(); if (itemAllNum > 1) { - swipeStackListener.onViewSwipedToRight(itemAllNum - componentList.size()); + swipeStackListener.onViewSwipedToRight(itemAllNum - componentList.size(), ((BaseSwipeCard) component).getText()); } if (itemAllNum == 1) { swipeStackListener.onStackEmpty(); @@ -217,8 +216,9 @@ public class SwipeDirectionalView extends StackLayout implements ICardState { public void rejectCard(Component component) { if (component instanceof BaseSwipeCard) { ((BaseSwipeCard) component).showReject(); + if (itemAllNum > 1) { - swipeStackListener.onViewSwipedToLeft(itemAllNum - componentList.size()); + swipeStackListener.onViewSwipedToLeft(itemAllNum - componentList.size(), ((BaseSwipeCard) component).getText()); } if (itemAllNum == 1) { swipeStackListener.onStackEmpty(); @@ -452,14 +452,14 @@ public class SwipeDirectionalView extends StackLayout implements ICardState { * * @param position The position of the view in the adapter currently in use. */ - void onViewSwipedToLeft(int position); + void onViewSwipedToLeft(int position, String text); /** * Called when a view has been dismissed to the right. * * @param position The position of the view in the adapter currently in use. */ - void onViewSwipedToRight(int position); + void onViewSwipedToRight(int position, String text); /** * Called when the last view has been dismissed. -- Gitee