Skip to content

Commit 2212d50

Browse files
committed
修复fail时又cancel的错误
2 parents 67f087c + 0f6a7b6 commit 2212d50

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
* Creator: Flood
3131
* Date: 2019-06-13
3232
* UseDes:
33-
*
33+
* <p>
3434
* 1、改变loading的大小 √
3535
* 2、收缩动画后不居中 √
3636
* 3、收缩后的大小随loading的大小决定 √
@@ -44,11 +44,11 @@
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 {
5051
private int curStatus = STATE.IDE; //当前的状态
51-
5252
interface STATE {
5353
int IDE = 0;
5454
int SHRINKING = 1;
@@ -137,8 +137,6 @@ private void init(Context context, AttributeSet attrs) {
137137

138138
}
139139

140-
141-
142140
/**
143141
* 设置收缩动画,主要用来收缩和恢复布局的宽度,动画开始前会保存一些收缩前的参数(文字,其他Drawable等)
144142
*/
@@ -178,11 +176,12 @@ public void onAnimationStart(Animator animation) {
178176
} else {
179177
//begin restore
180178
curStatus = STATE.RESTORING;
179+
stopLoading();
181180
if (mOnLoadingListener != null) {
182181
mOnLoadingListener.onRestoring();
183182
mOnLoadingListener.onLoadingStop();
184183
}
185-
stopLoading();
184+
186185
}
187186
}
188187

@@ -697,17 +696,14 @@ public void run() {
697696
@Override
698697
public void onAnimationStart(Animator animation) {
699698
super.onAnimationStart(animation);
699+
curStatus = STATE.END_DRAWABLE_SHOWING;
700700
if (mOnLoadingListener != null) {
701701
mOnLoadingListener.onEndDrawableAppear(!isFail, mEndDrawable);
702702
}
703-
curStatus = STATE.END_DRAWABLE_SHOWING;
704703
}
705704

706705
@Override
707706
public void onAnimationEnd(Animator animation) {
708-
if (mOnLoadingListener != null) {
709-
mOnLoadingListener.onLoadingStop();
710-
}
711707
if (isShowing) {
712708
postDelayed(mRunnable, mKeepDuration);
713709
}
@@ -728,10 +724,10 @@ private void show(boolean isFail) {
728724
}
729725

730726
//StopLoading
731-
if (mOnLoadingListener != null) {
727+
stopLoading();
728+
if (!enableShrink && mOnLoadingListener != null) {
732729
mOnLoadingListener.onLoadingStop();
733730
}
734-
stopLoading();
735731

736732
//end showing endDrawable
737733
if (isShowing) {
@@ -741,10 +737,10 @@ private void show(boolean isFail) {
741737
mAppearAnimator.start();
742738
isShowing = true;
743739

744-
//if mFailBitmap or mCompleteBitmap is null cancel appearAnim
740+
/* //if mFailBitmap or mCompleteBitmap is null cancel appearAnim
745741
if ((isFail && mFailBitmap == null) || (!isFail && mCompleteBitmap == null)) {
746742
cancel(true);
747-
}
743+
}*/
748744
}
749745

750746
/**
@@ -969,7 +965,7 @@ public void onLoadingStop() {
969965
}
970966

971967
@Override
972-
public void onEndDrawableAppear(boolean isSuccess, EndDrawable endDrawable) {
968+
public void onEndDrawableAppear(boolean isComplete, EndDrawable endDrawable) {
973969

974970
}
975971

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)