Skip to content

Commit 37afd5f

Browse files
committed
Added state to tell if button is loading or not
1 parent df78a4e commit 37afd5f

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444

4545
public class ProSwipeButton extends RelativeLayout implements View.OnTouchListener {
4646

47+
private static final int EXPANDED = 240;
48+
private static final int LOADING = 604;
49+
4750
private Context context;
4851
private View view;
4952
private GradientDrawable gradientDrawable;
@@ -53,6 +56,7 @@ public class ProSwipeButton extends RelativeLayout implements View.OnTouchListen
5356
private ImageView arrow2;
5457
private LinearLayout arrowHintContainer;
5558
private ProgressBar progressBar;
59+
private int state = EXPANDED;
5660

5761
//// TODO: 26/10/17 Add touch blocking
5862

@@ -256,6 +260,7 @@ public void performOnSwipe() {
256260
}
257261

258262
public void morphToCircle() {
263+
state = LOADING;
259264
animateFadeHide(context, arrowHintContainer);
260265
setOnTouchListener(null);
261266
ObjectAnimator cornerAnimation =
@@ -293,6 +298,7 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
293298
}
294299

295300
private void morphToRect() {
301+
state = EXPANDED;
296302
setOnTouchListener(this);
297303
ObjectAnimator cornerAnimation =
298304
ObjectAnimator.ofFloat(gradientDrawable, "cornerRadius", BTN_MORPHED_RADIUS, BTN_INIT_RADIUS);
@@ -395,6 +401,14 @@ private void tintArrowHint() {
395401
arrow2.setColorFilter(arrowColorInt, PorterDuff.Mode.MULTIPLY);
396402
}
397403

404+
public int getState() {
405+
return state;
406+
}
407+
408+
public void setState(int state) {
409+
this.state = state;
410+
}
411+
398412
public interface OnSwipeListener {
399413
void onSwipeConfirm();
400414
}
@@ -483,4 +497,8 @@ public void setOnSwipeListener(@Nullable OnSwipeListener customSwipeListener) {
483497
this.swipeListener = customSwipeListener;
484498
}
485499

500+
public OnSwipeListener getOnSwipeListener() {
501+
return this.swipeListener;
502+
}
503+
486504
}

0 commit comments

Comments
 (0)