Skip to content

Commit

Permalink
Merge branch 'magneticflux--master'
Browse files Browse the repository at this point in the history
  • Loading branch information
varunest committed Jan 26, 2017
2 parents 227f134 + 0b53daf commit 7c6d121
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions sparkbutton/src/main/java/com/varunest/sparkbutton/SparkButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ public void onAnimationCancel(Animator animation) {
animatorSet.start();
}

/**
* Returns whether the button is checked (Active) or not.
*
* @return
*/
public boolean isChecked() {
return isChecked;
}

/**
* Change Button State (Works only if both active and disabled image resource is defined)
*
Expand All @@ -198,14 +207,6 @@ public void setChecked(boolean flag) {
imageView.setColorFilter(isChecked ? activeImageTint : inActiveImageTint, PorterDuff.Mode.SRC_ATOP);
}

/**
* Returns whether the button is checked (Active) or not.
* @return
*/
public boolean isChecked() {
return isChecked;
}

public void setEventListener(SparkEventListener listener) {
this.listener = listener;
}
Expand Down Expand Up @@ -254,22 +255,19 @@ public boolean onTouch(View v, MotionEvent event) {
break;

case MotionEvent.ACTION_MOVE:
float x = event.getX();
float y = event.getY();
boolean isInside = (x > 0 && x < getWidth() && y > 0 && y < getHeight());
if (isPressed() != isInside) {
setPressed(isInside);
}
break;

case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
imageView.animate().scaleX(1).scaleY(1).setInterpolator(DECCELERATE_INTERPOLATOR);
if (isPressed()) {
performClick();
setPressed(false);
}
break;

case MotionEvent.ACTION_CANCEL:
imageView.animate().scaleX(1).scaleY(1).setInterpolator(DECCELERATE_INTERPOLATOR);
break;
}
return true;
}
Expand Down

0 comments on commit 7c6d121

Please sign in to comment.