From 6ed5a78d2c1c704f75bd09a0466fb1b26bd8fd52 Mon Sep 17 00:00:00 2001 From: Yuriy Budiyev Date: Tue, 1 May 2018 15:03:12 +0300 Subject: [PATCH] Dev --- .../CircularProgressBar.java | 98 ++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java b/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java index 188e2a1..c5b8128 100644 --- a/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java +++ b/src/main/java/com/budiyev/android/circularprogressbar/CircularProgressBar.java @@ -49,7 +49,7 @@ /** * Circular progress bar */ -public class CircularProgressBar extends View { +public final class CircularProgressBar extends View { private static final float DEFAULT_SIZE_DP = 48f; private static final float DEFAULT_MAXIMUM = 100f; private static final float DEFAULT_PROGRESS = 0f; @@ -168,6 +168,14 @@ public void setMaximum(final float maximum) { invalidate(); } + /** + * Start angle for non-indeterminate mode, between -360 and 360 degrees + */ + @FloatRange(from = -360f, to = 360f) + public float getStartAngle() { + return mStartAngle; + } + /** * Start angle for non-indeterminate mode, between -360 and 360 degrees */ @@ -177,6 +185,13 @@ public void setStartAngle(@FloatRange(from = -360f, to = 360f) final float angle invalidate(); } + /** + * Whether to animate progress for non-indeterminate mode + */ + public boolean isAnimateProgress() { + return mAnimateProgress; + } + /** * Whether to animate progress for non-indeterminate mode */ @@ -184,6 +199,14 @@ public void setAnimateProgress(final boolean animate) { mAnimateProgress = animate; } + /** + * Progress animation duration for non-indeterminate mode (in milliseconds) + */ + @IntRange(from = 0) + public long getProgressAnimationDuration() { + return mProgressAnimator.getDuration(); + } + /** * Progress animation duration for non-indeterminate mode (in milliseconds) */ @@ -197,6 +220,14 @@ public void setProgressAnimationDuration(@IntRange(from = 0) final long duration mProgressAnimator.setDuration(duration); } + /** + * Minimum angle for indeterminate mode, between 0 and 180 degrees + */ + @FloatRange(from = 0f, to = 180f) + public float getIndeterminateMinimumAngle() { + return mIndeterminateMinimumAngle; + } + /** * Minimum angle for indeterminate mode, between 0 and 180 degrees */ @@ -211,6 +242,14 @@ public void setIndeterminateMinimumAngle(@FloatRange(from = 0f, to = 180f) final } } + /** + * Rotation animation duration for indeterminate mode (in milliseconds) + */ + @IntRange(from = 0) + public long getIndeterminateRotationAnimationDuration() { + return mIndeterminateStartAnimator.getDuration(); + } + /** * Rotation animation duration for indeterminate mode (in milliseconds) */ @@ -224,6 +263,14 @@ public void setIndeterminateRotationAnimationDuration(@IntRange(from = 0) final } } + /** + * Sweep animation duration for indeterminate mode (in milliseconds) + */ + @IntRange(from = 0) + public long getIndeterminateSweepAnimationDuration() { + return mIndeterminateSweepAnimator.getDuration(); + } + /** * Sweep animation duration for indeterminate mode (in milliseconds) */ @@ -237,6 +284,14 @@ public void setIndeterminateSweepAnimationDuration(@IntRange(from = 0) final lon } } + /** + * Foreground stroke cap + */ + @NonNull + public Paint.Cap getForegroundStrokeCap() { + return mBackgroundStrokePaint.getStrokeCap(); + } + /** * Foreground stroke cap */ @@ -246,6 +301,14 @@ public void setForegroundStrokeCap(@NonNull final Paint.Cap cap) { invalidate(); } + /** + * Foreground stroke color + */ + @ColorInt + public int getForegroundStrokeColor() { + return mForegroundStrokePaint.getColor(); + } + /** * Foreground stroke color */ @@ -254,6 +317,14 @@ public void setForegroundStrokeColor(@ColorInt final int color) { invalidate(); } + /** + * Foreground stroke width (in pixels) + */ + @FloatRange(from = 0f, to = Float.MAX_VALUE) + public float getForegroundStrokeWidth() { + return mForegroundStrokePaint.getStrokeWidth(); + } + /** * Foreground stroke width (in pixels) */ @@ -264,14 +335,30 @@ public void setForegroundStrokeWidth(@FloatRange(from = 0f, to = Float.MAX_VALUE invalidate(); } + /** + * Background stroke color + */ + @ColorInt + public int getBackgroundStrokeColor() { + return mBackgroundStrokePaint.getColor(); + } + /** * Background stroke color */ public void setBackgroundStrokeColor(@ColorInt final int color) { - mForegroundStrokePaint.setColor(color); + mBackgroundStrokePaint.setColor(color); invalidate(); } + /** + * Background stroke width (in pixels) + */ + @FloatRange(from = 0f, to = Float.MAX_VALUE) + public float getBackgroundStrokeWidth() { + return mBackgroundStrokePaint.getStrokeWidth(); + } + /** * Background stroke width (in pixels) */ @@ -282,6 +369,13 @@ public void setBackgroundStrokeWidth(@FloatRange(from = 0f, to = Float.MAX_VALUE invalidate(); } + /** + * Whether to draw background stroke + */ + public boolean isDrawBackgroundStroke() { + return mDrawBackgroundStroke; + } + /** * Whether to draw background stroke */