Skip to content

Commit 0f6a7b6

Browse files
committed
修复fail时又cancel的错误
1 parent a5ae6d1 commit 0f6a7b6

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
* 9、设置完Drawable大小后,start后再次设置rootView大小失控,是因为原来是wrap_content √
4545
* 10、start和compete同时按Loading没有关 √
4646
* 11、loading完后设置loading大小好像是无效的
47+
* 12、如果是没有EndDrawable但是有文字,那是否也要停留一段时间呢?
4748
*/
4849
@SuppressWarnings({"UnusedReturnValue,SameParameterValue", "unused"})
4950
public class LoadingButton extends DrawableTextView {
@@ -138,7 +139,6 @@ private void init(Context context, AttributeSet attrs) {
138139
}
139140

140141

141-
142142
/**
143143
* 设置收缩动画,主要用来收缩和恢复布局的宽度,动画开始前会保存一些收缩前的参数(文字,其他Drawable等)
144144
*/
@@ -178,11 +178,12 @@ public void onAnimationStart(Animator animation) {
178178
} else {
179179
//begin restore
180180
curStatus = STATE.RESTORING;
181+
stopLoading();
181182
if (mOnLoadingListener != null) {
182183
mOnLoadingListener.onRestoring();
183184
mOnLoadingListener.onLoadingStop();
184185
}
185-
stopLoading();
186+
186187
}
187188
}
188189

@@ -697,17 +698,14 @@ public void run() {
697698
@Override
698699
public void onAnimationStart(Animator animation) {
699700
super.onAnimationStart(animation);
701+
curStatus = STATE.END_DRAWABLE_SHOWING;
700702
if (mOnLoadingListener != null) {
701703
mOnLoadingListener.onEndDrawableAppear(!isFail, mEndDrawable);
702704
}
703-
curStatus = STATE.END_DRAWABLE_SHOWING;
704705
}
705706

706707
@Override
707708
public void onAnimationEnd(Animator animation) {
708-
if (mOnLoadingListener != null) {
709-
mOnLoadingListener.onLoadingStop();
710-
}
711709
if (isShowing) {
712710
postDelayed(mRunnable, mKeepDuration);
713711
}
@@ -728,10 +726,10 @@ private void show(boolean isFail) {
728726
}
729727

730728
//StopLoading
731-
if (mOnLoadingListener != null) {
729+
stopLoading();
730+
if (!enableShrink && mOnLoadingListener != null) {
732731
mOnLoadingListener.onLoadingStop();
733732
}
734-
stopLoading();
735733

736734
//end showing endDrawable
737735
if (isShowing) {
@@ -741,10 +739,10 @@ private void show(boolean isFail) {
741739
mAppearAnimator.start();
742740
isShowing = true;
743741

744-
//if mFailBitmap or mCompleteBitmap is null cancel appearAnim
742+
/* //if mFailBitmap or mCompleteBitmap is null cancel appearAnim
745743
if ((isFail && mFailBitmap == null) || (!isFail && mCompleteBitmap == null)) {
746744
cancel(true);
747-
}
745+
}*/
748746
}
749747

750748
/**
@@ -969,7 +967,7 @@ public void onLoadingStop() {
969967
}
970968

971969
@Override
972-
public void onEndDrawableAppear(boolean isSuccess, EndDrawable endDrawable) {
970+
public void onEndDrawableAppear(boolean isComplete, EndDrawable endDrawable) {
973971

974972
}
975973

README.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@
2323

2424
dependencies {
2525
//Androidx
26-
implementation 'com.github.FlodCoding:LoadingButton:1.0.0-alpha2'
26+
implementation 'com.github.FlodCoding:LoadingButton:1.0.0-alpha3'
2727

2828
//Support-appcompat
29-
implementation 'com.github.FlodCoding:LoadingButton:1.0.0-alpha2-support'
29+
implementation 'com.github.FlodCoding:LoadingButton:1.0.0-alpha3-support'
3030
}
3131

3232

@@ -55,6 +55,12 @@
5555
```
5656
### Code
5757
```
58+
59+
loadingBtn.start(); //开始加载
60+
loadingBtn.complete(); //加载成功
61+
loadingBtn.fail(); //加载失败
62+
loadingBtn.cancel(); //加载取消
63+
5864
loadingBtn.setEnableShrink(true)
5965
.setDisableClickOnLoading(true)
6066
.setShrinkDuration(450)

0 commit comments

Comments
 (0)