CircularProgressLayout
public class CircularProgressLayout extends FrameLayout
| java.lang.Object | ||||
| ↳ | android.view.View | |||
| ↳ | android.view.ViewGroup | |||
| ↳ | android.widget.FrameLayout | |||
| ↳ | androidx.wear.widget.CircularProgressLayout |
CircularProgressLayout adds a circular countdown timer behind the view it contains, typically used to automatically confirm an operation after a short delay has elapsed.
The developer can specify a countdown interval via setTotalTime and a listener via setOnTimerFinishedListener to be called when the time has elapsed after startTimer has been called. Tap action can be received via setOnClickListener and can be used to cancel the timer via stopTimer method.
Alternatively, this layout can be used to show indeterminate progress by calling setIndeterminate method.
Summary
Nested types |
|---|
public interface CircularProgressLayout.OnTimerFinishedListenerInterface to implement for listening to |
Public constructors |
|---|
CircularProgressLayout(Context context) |
CircularProgressLayout(Context context, AttributeSet attrs) |
CircularProgressLayout( |
CircularProgressLayout( |
Public methods |
|
|---|---|
@ColorInt int |
Returns the background color of the |
int[] |
Returns the color scheme colors of the progress drawable |
@Nullable CircularProgressLayout.OnTimerFinishedListener |
Returns the |
@NonNull CircularProgressDrawable |
Returns the |
float |
Returns the starting rotation of the progress drawable. |
float |
Returns the stroke width of the progress drawable in pixels. |
long |
Returns the total time in milliseconds for the timer to countdown to. |
boolean |
Returns if progress is showing as an indeterminate spinner. |
boolean |
Returns if the timer is running. |
void |
setBackgroundColor(@ColorInt int color)Sets the background color of the |
void |
setColorSchemeColors(int[] colors)Sets the color scheme colors of the progress drawable, which is equivalent to calling |
void |
setIndeterminate(boolean indeterminate)Sets if progress should be shown as an indeterminate spinner. |
void |
Sets the |
void |
setStartingRotation(float rotation)Sets the starting rotation for the progress drawable to start from. |
void |
setStrokeWidth(float strokeWidth)Sets the stroke width of the progress drawable in pixels. |
void |
setTotalTime(long totalTime)Sets the total time in milliseconds for the timer to countdown to. |
void |
Starts the timer countdown. |
void |
Stops the timer countdown. |
Protected methods |
|
|---|---|
void |
|
void |
onLayout(boolean changed, int left, int top, int right, int bottom) |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Inherited methods |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
CircularProgressLayout
public CircularProgressLayout(Context context, AttributeSet attrs)
CircularProgressLayout
public CircularProgressLayout(
Context context,
AttributeSet attrs,
int defStyleAttr
)
CircularProgressLayout
public CircularProgressLayout(
Context context,
AttributeSet attrs,
int defStyleAttr,
int defStyleRes
)
Public methods
getBackgroundColor
public @ColorInt int getBackgroundColor()
Returns the background color of the CircularProgressDrawable.
| Returns | |
|---|---|
@ColorInt int |
an ARGB color |
getColorSchemeColors
public int[] getColorSchemeColors()
Returns the color scheme colors of the progress drawable
| Returns | |
|---|---|
int[] |
list of ARGB colors |
getOnTimerFinishedListener
public @Nullable CircularProgressLayout.OnTimerFinishedListener getOnTimerFinishedListener()
Returns the OnTimerFinishedListener that is registered to this layout.
| Returns | |
|---|---|
@Nullable CircularProgressLayout.OnTimerFinishedListener |
registered |
getProgressDrawable
public @NonNull CircularProgressDrawable getProgressDrawable()
Returns the CircularProgressDrawable used as background of this layout.
getStartingRotation
public float getStartingRotation()
Returns the starting rotation of the progress drawable.
| Returns | |
|---|---|
float |
starting rotation from [0..1] |
getStrokeWidth
public float getStrokeWidth()
Returns the stroke width of the progress drawable in pixels.
| Returns | |
|---|---|
float |
stroke width in pixels |
getTotalTime
public long getTotalTime()
Returns the total time in milliseconds for the timer to countdown to.
| Returns | |
|---|---|
long |
total time in milliseconds |
isIndeterminate
public boolean isIndeterminate()
Returns if progress is showing as an indeterminate spinner.
| Returns | |
|---|---|
boolean |
|
isTimerRunning
public boolean isTimerRunning()
Returns if the timer is running.
| Returns | |
|---|---|
boolean |
|
setBackgroundColor
public void setBackgroundColor(@ColorInt int color)
Sets the background color of the CircularProgressDrawable, which is drawn as a circle inside the progress drawable. Colors are in ARGB format defined in Color.
| Parameters | |
|---|---|
@ColorInt int color |
an ARGB color |
setColorSchemeColors
public void setColorSchemeColors(int[] colors)
Sets the color scheme colors of the progress drawable, which is equivalent to calling setColorSchemeColors method on background drawable of this layout.
| Parameters | |
|---|---|
int[] colors |
list of ARGB colors |
setIndeterminate
public void setIndeterminate(boolean indeterminate)
Sets if progress should be shown as an indeterminate spinner.
| Parameters | |
|---|---|
boolean indeterminate |
|
setOnTimerFinishedListener
public void setOnTimerFinishedListener(
@Nullable CircularProgressLayout.OnTimerFinishedListener listener
)
Sets the OnTimerFinishedListener to be notified when timer countdown is finished.
| Parameters | |
|---|---|
@Nullable CircularProgressLayout.OnTimerFinishedListener listener |
|
setStartingRotation
public void setStartingRotation(float rotation)
Sets the starting rotation for the progress drawable to start from. Default starting rotation is 0.75 and it corresponds clockwise geometric 270 degrees (12 o'clock on a watch)
| Parameters | |
|---|---|
float rotation |
starting rotation from [0..1] |
setStrokeWidth
public void setStrokeWidth(float strokeWidth)
Sets the stroke width of the progress drawable in pixels.
| Parameters | |
|---|---|
float strokeWidth |
stroke width in pixels |
setTotalTime
public void setTotalTime(long totalTime)
Sets the total time in milliseconds for the timer to countdown to. Calling this method while the timer is already running will not change the duration of the current timer.
| Parameters | |
|---|---|
long totalTime |
total time in milliseconds |
startTimer
public void startTimer()
Starts the timer countdown. Once the countdown is finished, if there is an OnTimerFinishedListener registered by setOnTimerFinishedListener method, its onTimerFinished method is called. If this method is called while there is already a running timer, it will restart the timer.