Skip to content

Commit 29da455

Browse files
committed
Choose to expand button after success or failure
1 parent db70448 commit 29da455

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

app/src/main/java/in/shadowfax/proswipebutton_app/MainActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public void onSwipeConfirm() {
2424
new Handler().postDelayed(new Runnable() {
2525
@Override
2626
public void run() {
27-
proSwipeBtn.showResultIcon(true);
27+
proSwipeBtn.showResultIcon(true, false);
2828
}
2929
}, 2000);
3030
}
@@ -37,7 +37,7 @@ public void onSwipeConfirm() {
3737
new Handler().postDelayed(new Runnable() {
3838
@Override
3939
public void run() {
40-
proSwipeBtnError.showResultIcon(false);
40+
proSwipeBtnError.showResultIcon(false, true);
4141
}
4242
}, 2000);
4343
}

proswipebutton/src/main/java/in/shadowfax/proswipebutton/ProSwipeButton.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ private void showProgressBar() {
358358
contentContainer.addView(progressBar);
359359
}
360360

361-
public void showResultIcon(boolean isSuccess) {
361+
public void showResultIcon(boolean isSuccess, boolean shouldReset) {
362362
animateFadeHide(context, progressBar);
363363

364364
final AppCompatImageView failureIcon = new AppCompatImageView(context);
@@ -375,7 +375,7 @@ public void showResultIcon(boolean isSuccess) {
375375
contentContainer.addView(failureIcon);
376376
animateFadeShow(context, failureIcon);
377377

378-
if (!isSuccess) {
378+
if (shouldReset) {
379379
// expand the btn again
380380
new Handler().postDelayed(new Runnable() {
381381
@Override
@@ -390,6 +390,10 @@ public void run() {
390390
}
391391
}
392392

393+
public void showResultIcon(boolean isSuccess) {
394+
showResultIcon(isSuccess, !isSuccess);
395+
}
396+
393397
private void tintArrowHint() {
394398
arrow1.setColorFilter(arrowColorInt, PorterDuff.Mode.MULTIPLY);
395399
arrow2.setColorFilter(arrowColorInt, PorterDuff.Mode.MULTIPLY);

0 commit comments

Comments
 (0)