From 0d67dcd90fe68aed1610801dc53b69381d635462 Mon Sep 17 00:00:00 2001
From: zxd191990 <1713664308@qq.com>
Date: Mon, 12 Apr 2021 18:42:15 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=8C=85=E5=90=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.idea/$PROJECT_FILE$ | 11 +++++++
.idea/.gitignore | 3 ++
.idea/checkstyle-idea.xml | 16 +++++++++
.idea/compiler.xml | 6 ++++
.idea/gradle.xml | 22 +++++++++++++
.idea/jarRepositories.xml | 30 +++++++++++++++++
.idea/misc.xml | 7 ++++
.idea/qaplug_profiles.xml | 12 +++++++
.idea/vcs.xml | 6 ++++
README.md | 4 +--
entry/build.gradle | 11 -------
.../utils/ViewCreateHelper.java | 21 +++++++++---
.../main/resources/base/layout/text_item.xml | 4 +--
.../base/layout/text_item_scroll_test.xml | 4 +--
library/src/main/config.json | 4 +--
.../ExpandableTextView.java | 33 ++++++++++++++-----
.../expandabletextview/TypedAttrUtils.java | 2 +-
17 files changed, 164 insertions(+), 32 deletions(-)
create mode 100644 .idea/$PROJECT_FILE$
create mode 100644 .idea/.gitignore
create mode 100644 .idea/checkstyle-idea.xml
create mode 100644 .idea/compiler.xml
create mode 100644 .idea/gradle.xml
create mode 100644 .idea/jarRepositories.xml
create mode 100644 .idea/misc.xml
create mode 100644 .idea/qaplug_profiles.xml
create mode 100644 .idea/vcs.xml
rename library/src/main/java/com/ms/square/{ohos => android}/expandabletextview/ExpandableTextView.java (95%)
rename library/src/main/java/com/ms/square/{ohos => android}/expandabletextview/TypedAttrUtils.java (98%)
diff --git a/.idea/$PROJECT_FILE$ b/.idea/$PROJECT_FILE$
new file mode 100644
index 0000000..58b7e3e
--- /dev/null
+++ b/.idea/$PROJECT_FILE$
@@ -0,0 +1,11 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000..26d3352
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000..9d45f43
--- /dev/null
+++ b/.idea/checkstyle-idea.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000..61a9130
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
new file mode 100644
index 0000000..10f0aec
--- /dev/null
+++ b/.idea/gradle.xml
@@ -0,0 +1,22 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000..1dfcd02
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..7bf1527
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/qaplug_profiles.xml b/.idea/qaplug_profiles.xml
new file mode 100644
index 0000000..9a7566c
--- /dev/null
+++ b/.idea/qaplug_profiles.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..94a25f7
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 42131d7..e23907f 100644
--- a/README.md
+++ b/README.md
@@ -40,7 +40,7 @@
使用该库非常简单,只需查看提供的示例的源代码。(查看ViewCreateHelper.java中在ScrollView和ListContainer中的使用)
```示例XML
-
-
+
```
```java
diff --git a/entry/build.gradle b/entry/build.gradle
index e0e7cd4..393918a 100644
--- a/entry/build.gradle
+++ b/entry/build.gradle
@@ -1,17 +1,6 @@
apply plugin: 'com.huawei.ohos.hap'
apply plugin: 'com.huawei.ohos.decctest'
ohos {
- signingConfigs {
- debug {
- storeFile file('E:\\hongmeng\\trunk\\keyStore 二期\\ExpandableTextView\\root_1.p12')
- storePassword '00000020EF5D83995F16225C27A992A2F491459B7286F5EAF942B26161119B95D7B58A3580CC023F529511701D8FD606'
- keyAlias = 'hos_platform_os'
- keyPassword '00000020E22C3F8C74E64EA5B72F4F9E4D7A9176D56075099118E157F703C7507997A895734DDEC0A0657F4842DED698'
- signAlg = 'SHA256withECDSA'
- profile file('E:\\hongmeng\\trunk\\keyStore 二期\\ExpandableTextView\\ExpandableTextViewDebug.p7b')
- certpath file('E:\\hongmeng\\trunk\\keyStore 二期\\ExpandableTextView\\root.cer')
- }
- }
compileSdkVersion 5
defaultConfig {
compatibleSdkVersion 4
diff --git a/entry/src/main/java/com/hos/expandabletextview/utils/ViewCreateHelper.java b/entry/src/main/java/com/hos/expandabletextview/utils/ViewCreateHelper.java
index b70902f..9399e2a 100644
--- a/entry/src/main/java/com/hos/expandabletextview/utils/ViewCreateHelper.java
+++ b/entry/src/main/java/com/hos/expandabletextview/utils/ViewCreateHelper.java
@@ -18,7 +18,7 @@ package com.hos.expandabletextview.utils;
import com.hos.expandabletextview.ResourceTable;
import com.hos.expandabletextview.adapter.ListAdapter;
import com.hos.expandabletextview.adapter.ViewHolder;
-import com.ms.square.ohos.expandabletextview.ExpandableTextView;
+import com.ms.square.android.expandabletextview.ExpandableTextView;
import ohos.agp.components.*;
import ohos.agp.render.Paint;
import ohos.app.Context;
@@ -83,8 +83,17 @@ public final class ViewCreateHelper {
ExpandableTextView expandableTextView = (ExpandableTextView)
component.findComponentById(ResourceTable.Id_expandable);
expandableTextView.setText(slice.getString(ResourceTable.String_dummy_text2));
- expandableTextView.setOnExpandStateChangeListener((textView, isExpanded) ->
- MyToast.show(slice, isExpanded ? "Expanded" : "Collapsed", MyToast.ToastLayout.BOTTOM));
+ expandableTextView.setOnExpandStateChangeListener(new ExpandableTextView.OnExpandStateChangeListener() {
+ @Override
+ public void onExpandStateChanged(Text textView) {
+
+ }
+
+ @Override
+ public void expandStateChangedToast(boolean isExpanded) {
+ MyToast.show(slice, isExpanded ? "Expanded" : "Collapsed", MyToast.ToastLayout.BOTTOM);
+ }
+ });
}
}
return rootLayout;
@@ -123,9 +132,13 @@ public final class ViewCreateHelper {
expandableTextView.setText(slice.getString(ResourceTable.String_dummy_text2));
expandableTextView.setOnExpandStateChangeListener(new ExpandableTextView.OnExpandStateChangeListener() {
@Override
- public void onExpandStateChanged(Text textView, boolean isExpanded) {
+ public void onExpandStateChanged(Text textView) {
int position = Integer.valueOf(textView.getTag().toString()).intValue();
listAdapter.notifyDataSetItemChanged(position + 1);
+ }
+
+ @Override
+ public void expandStateChangedToast(boolean isExpanded) {
MyToast.show(slice, isExpanded ? "Expanded" : "Collapsed", MyToast.ToastLayout.BOTTOM);
}
});
diff --git a/entry/src/main/resources/base/layout/text_item.xml b/entry/src/main/resources/base/layout/text_item.xml
index 3ad58a1..4456a78 100644
--- a/entry/src/main/resources/base/layout/text_item.xml
+++ b/entry/src/main/resources/base/layout/text_item.xml
@@ -6,7 +6,7 @@
ohos:width="match_parent"
ohos:orientation="vertical">
-
-
+
-
-
+
\ No newline at end of file
diff --git a/library/src/main/config.json b/library/src/main/config.json
index f523799..d2a5e37 100644
--- a/library/src/main/config.json
+++ b/library/src/main/config.json
@@ -1,6 +1,6 @@
{
"app": {
- "bundleName": "com.ms.square.ohos.expandabletextview",
+ "bundleName": "com.ms.square.android.expandabletextview",
"vendor": "loopj",
"version": {
"code": 1,
@@ -14,7 +14,7 @@
},
"deviceConfig": {},
"module": {
- "package": "com.ms.square.ohos.expandabletextview",
+ "package": "com.ms.square.android.expandabletextview",
"deviceType": [
"phone"
],
diff --git a/library/src/main/java/com/ms/square/ohos/expandabletextview/ExpandableTextView.java b/library/src/main/java/com/ms/square/android/expandabletextview/ExpandableTextView.java
similarity index 95%
rename from library/src/main/java/com/ms/square/ohos/expandabletextview/ExpandableTextView.java
rename to library/src/main/java/com/ms/square/android/expandabletextview/ExpandableTextView.java
index 277224e..7488f5e 100644
--- a/library/src/main/java/com/ms/square/ohos/expandabletextview/ExpandableTextView.java
+++ b/library/src/main/java/com/ms/square/android/expandabletextview/ExpandableTextView.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.ms.square.ohos.expandabletextview;
+package com.ms.square.android.expandabletextview;
import ohos.agp.animation.Animator;
import ohos.agp.animation.AnimatorValue;
@@ -161,8 +161,13 @@ public class ExpandableTextView extends DirectionalLayout implements
super.setOrientation(orientation);
}
+ AnimatorValue animation = new AnimatorValue();
+
@Override
public void onClick(Component component) {
+ if (animation.isRunning()) {
+ return;
+ }
if (expandCollapse.getVisibility() != Component.VISIBLE) {
return;
}
@@ -183,7 +188,6 @@ public class ExpandableTextView extends DirectionalLayout implements
}
// 动效
- AnimatorValue animation = new AnimatorValue();
animation.setDuration(animationDuration);
animation.setStateChangedListener(new Animator.StateChangedListener() {
@Override
@@ -204,9 +208,7 @@ public class ExpandableTextView extends DirectionalLayout implements
@Override
public void onEnd(Animator animator) {
// notify the listener
- if (mListener != null) {
- mListener.onExpandStateChanged(expandText, !mCollapsed);
- }
+ mListener.expandStateChangedToast(!mCollapsed);
}
@Override
@@ -234,8 +236,18 @@ public class ExpandableTextView extends DirectionalLayout implements
if (Float.compare(animAlphaStart, 1.0f) != 0) {
applyAlphaAnimation(expandText, animAlphaStart + interpolatedTime * (1.0f - animAlphaStart));
}
+
+ getContext().getUITaskDispatcher().delayDispatch(new Runnable() {
+ @Override
+ public void run() {
+ if (mListener != null) {
+ mListener.onExpandStateChanged(expandText);
+ }
+ }
+ }, 10);
}
});
+
animation.start();
}
@@ -300,6 +312,7 @@ public class ExpandableTextView extends DirectionalLayout implements
setOrientation(Component.VERTICAL);
//add绘制的回调
addDrawTask(mDrawTask);
+
}
private static int getRealTextViewHeight(Text textView) {
@@ -379,10 +392,14 @@ public class ExpandableTextView extends DirectionalLayout implements
/**
* Called when the expand/collapse animation has been finished
*
- * @param textView - TextView being expanded/collapsed
- * @param isExpanded - true if the TextView has been expanded
+ * @param textView - TextView being expanded/collapsed
+ */
+ void onExpandStateChanged(Text textView);
+
+ /**
+ * 状态改变时的提示语
*/
- void onExpandStateChanged(Text textView, boolean isExpanded);
+ void expandStateChangedToast(boolean isExpanded);
}
interface ExpandIndicatorController {
diff --git a/library/src/main/java/com/ms/square/ohos/expandabletextview/TypedAttrUtils.java b/library/src/main/java/com/ms/square/android/expandabletextview/TypedAttrUtils.java
similarity index 98%
rename from library/src/main/java/com/ms/square/ohos/expandabletextview/TypedAttrUtils.java
rename to library/src/main/java/com/ms/square/android/expandabletextview/TypedAttrUtils.java
index 27b5c6b..ca585e9 100644
--- a/library/src/main/java/com/ms/square/ohos/expandabletextview/TypedAttrUtils.java
+++ b/library/src/main/java/com/ms/square/android/expandabletextview/TypedAttrUtils.java
@@ -13,7 +13,7 @@
* limitations under the License.
*
*/
-package com.ms.square.ohos.expandabletextview;
+package com.ms.square.android.expandabletextview;
import ohos.agp.components.Attr;
--
Gitee