diff --git a/CHANGELOG.md b/CHANGELOG.md index 9dd968a94118e2064287f649c514dbcb53079416..70246f5ddeebfbc62e17983159676ed898daaa6f 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 b34d2fa03bffa1acd071bb852319dc5959bf1eaa..520771cf91d70ec4296ca5c1710b7e0ee3173fc3 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 49bd550bd2daf5240e23681f66bd1c5b835cc430..2768865bcfbf779e877abb9be3f251524343ff75 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 1e80947047db318aa081ecf7692da17bacfe6f62..da226dcf73d2b3e40d3f5da8700da377bf1477e6 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 3f81e9104574c9a26ec062325eb3022f5d8ff640..b5e2c7beba3446ece417679a463c4759916fcaf0 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 ebb7bafed845d3907938a53388393c4bdb7f38fc..e0a1a31880133907ad6209a57daaca6c0e81f6bc 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 9d373f1101be69156349b3f960d747374c48fabc..4f2e24b99ab3521613ee41191228ad172406bdbb 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 bc8414fa13a5e9d6120b300606d0a115ebe4f128..f7666e47561d514b2a76d5a7dfbb43ede86da92a 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 cb7e4983ac89ea64ab06d7763374346446a8d3a1..5aba80460da437bd1aa3718725d32d25bf06de7f 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 9628c90230c8872989121add84f480b3f65634e9..3c1074e0e7b11e7f6eac5f163c8898534cbc39e1 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.