Skip to content

Commit

Permalink
Dev
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-budiyev committed Dec 17, 2017
1 parent fa47bea commit 7a12bbf
Showing 1 changed file with 21 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -164,9 +164,10 @@ public void setMaximum(float maximum) {
}

/**
* Start angle for non-indeterminate mode
* Start angle for non-indeterminate mode (in degrees)
*/
public void setStartAngle(@FloatRange(from = 0f, to = 360f) float angle) {
public void setStartAngle(@FloatRange(from = -360f, to = 360f) float angle) {
checkStartAngle(angle);
mStartAngle = angle;
invalidate();
}
Expand All @@ -179,9 +180,10 @@ public void setAnimateProgress(boolean animate) {
}

/**
* Minimum angle for indeterminate mode
* Minimum angle for indeterminate mode (in degrees)
*/
public void setIndeterminateMinimumAngle(@FloatRange(from = 0f, to = 360f) float angle) {
public void setIndeterminateMinimumAngle(@FloatRange(from = 0f, to = 120f) float angle) {
checkIndeterminateMinimumAngle(angle);
stopIndeterminateAnimations();
mIndeterminateMinimumAngle = angle;
mIndeterminateSweepAnimator.setFloatValues(360f - angle * 2f);
Expand Down Expand Up @@ -400,6 +402,8 @@ private void initialize(@NonNull Context context, @Nullable AttributeSet attribu
}
}
}
checkStartAngle(mStartAngle);
checkIndeterminateMinimumAngle(mIndeterminateMinimumAngle);
mProgressAnimator.setInterpolator(new DecelerateInterpolator());
mProgressAnimator.addUpdateListener(new ProgressUpdateListener());
mIndeterminateStartAnimator.setFloatValues(360f);
Expand Down Expand Up @@ -476,6 +480,19 @@ private void startIndeterminateAnimations() {
}
}

private void checkStartAngle(float angle) {
if (angle < -360f || angle > 360f) {
throw new IllegalArgumentException("Start angle value should be between -360 and 360 degrees (inclusive)");
}
}

private void checkIndeterminateMinimumAngle(float angle) {
if (angle < 0f || angle > 120f) {
throw new IllegalArgumentException(
"Indeterminate minimum angle value should be between 0 and 120 degrees (inclusive)");
}
}

private final class ProgressUpdateListener implements ValueAnimator.AnimatorUpdateListener {
@Override
public void onAnimationUpdate(ValueAnimator animation) {
Expand Down

0 comments on commit 7a12bbf

Please sign in to comment.