Skip to content

Commit 95b8744

Browse files
committed
优化重复complete文字显示问题
1 parent 5425da3 commit 95b8744

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

.idea/gradle.xml

Lines changed: 0 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Loadingbutton/src/main/java/com/flod/loadingbutton/LoadingButton.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ interface STATE {
7373
private int mLoadingSize;
7474
private int mLoadingPosition;
7575

76+
private boolean isSizeChanging; //当前布局尺寸正发生改变
7677
private boolean nextShrinkReverse; //下一步是否是恢复动画
7778
private boolean isCancel; //是取消当前动画
7879
private boolean isFail;
@@ -164,12 +165,13 @@ public void onAnimationStart(Animator animation) {
164165
if (!nextShrinkReverse) {
165166
//begin shrink
166167
curStatus = STATE.SHRINKING;
168+
isSizeChanging = true;
167169
if (mOnLoadingListener != null) {
168170
mOnLoadingListener.onShrinking();
169171
}
170172

171173
saveStatus();
172-
setText("");
174+
LoadingButton.super.setText("",BufferType.NORMAL);
173175
setCompoundDrawablePadding(0);
174176
setCompoundDrawablesRelative(mLoadingDrawable, null, null, null);
175177
setEnableTextInCenter(false);
@@ -197,6 +199,7 @@ public void onAnimationEnd(Animator animation) {
197199
} else {
198200
//restore over
199201
curStatus = STATE.IDE;
202+
isSizeChanging = false;
200203
restoreStatus();
201204
endCallbackListener();
202205
nextShrinkReverse = false;
@@ -611,10 +614,11 @@ public void setCompoundDrawablePadding(int pad) {
611614
}
612615

613616

617+
614618
@Override
615619
public void setText(CharSequence text, BufferType type) {
616-
if (enableShrink && (curStatus != STATE.IDE)) {
617-
text = "";
620+
if (enableShrink && isSizeChanging) {
621+
return;
618622
}
619623
super.setText(text, type);
620624
}

0 commit comments

Comments
 (0)