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 7c39634 commit c235c4d
Showing 1 changed file with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ public void setProgressAnimationDuration(@IntRange(from = 0) long duration) {
/**
* Minimum angle for indeterminate mode, between 0 and 120 degrees
*/
public void setIndeterminateMinimumAngle(@FloatRange(from = 0f, to = 120f) float angle) {
public void setIndeterminateMinimumAngle(@FloatRange(from = 0f, to = 180f) float angle) {
checkIndeterminateMinimumAngle(angle);
stopIndeterminateAnimations();
mIndeterminateMinimumAngle = angle;
Expand Down Expand Up @@ -244,6 +244,7 @@ public void setForegroundStrokeColor(@ColorInt int color) {
* Foreground stroke width (in pixels)
*/
public void setForegroundStrokeWidth(@FloatRange(from = 0f, to = Float.MAX_VALUE) float width) {
checkWidth(width);
mForegroundStrokePaint.setStrokeWidth(width);
invalidateDrawRect();
invalidate();
Expand All @@ -261,6 +262,7 @@ public void setBackgroundStrokeColor(@ColorInt int color) {
* Background stroke width (in pixels)
*/
public void setBackgroundStrokeWidth(@FloatRange(from = 0f, to = Float.MAX_VALUE) float width) {
checkWidth(width);
mBackgroundStrokePaint.setStrokeWidth(width);
invalidateDrawRect();
invalidate();
Expand Down Expand Up @@ -407,12 +409,14 @@ private void initialize(@NonNull Context context, @Nullable AttributeSet attribu
mBackgroundStrokePaint.setColor(attributes
.getColor(R.styleable.CircularProgressBar_backgroundStrokeColor,
DEFAULT_BACKGROUND_STROKE_COLOR));
mForegroundStrokePaint.setStrokeWidth(attributes
.getDimension(R.styleable.CircularProgressBar_foregroundStrokeWidth,
Math.round(DEFAULT_FOREGROUND_STROKE_WIDTH_DP * displayMetrics.density)));
mBackgroundStrokePaint.setStrokeWidth(attributes
.getDimension(R.styleable.CircularProgressBar_backgroundStrokeWidth,
Math.round(DEFAULT_BACKGROUND_STROKE_WIDTH_DP * displayMetrics.density)));
float foregroundWidth = attributes.getDimension(R.styleable.CircularProgressBar_foregroundStrokeWidth,
Math.round(DEFAULT_FOREGROUND_STROKE_WIDTH_DP * displayMetrics.density));
checkWidth(foregroundWidth);
mForegroundStrokePaint.setStrokeWidth(foregroundWidth);
float backgroundWidth = attributes.getDimension(R.styleable.CircularProgressBar_backgroundStrokeWidth,
Math.round(DEFAULT_BACKGROUND_STROKE_WIDTH_DP * displayMetrics.density));
checkWidth(backgroundWidth);
mBackgroundStrokePaint.setStrokeWidth(backgroundWidth);
mAnimateProgress = attributes
.getBoolean(R.styleable.CircularProgressBar_animateProgress, DEFAULT_ANIMATE_PROGRESS);
mDrawBackgroundStroke = attributes.getBoolean(R.styleable.CircularProgressBar_drawBackgroundStroke,
Expand Down Expand Up @@ -508,9 +512,9 @@ private void checkStartAngle(float angle) {
}

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

Expand All @@ -520,6 +524,12 @@ private void checkAnimationDuration(long duration) {
}
}

private void checkWidth(float width) {
if (width < 0f) {
throw new IllegalArgumentException("Width can't be negative");
}
}

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

0 comments on commit c235c4d

Please sign in to comment.