added in version 26.1.0
belongs to Maven artifact com.android.support:wear:28.0.0-alpha1

CircularProgressLayout

public class CircularProgressLayout
extends FrameLayout

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.FrameLayout
         ↳ android.support.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(long) and a listener via setOnTimerFinishedListener(OnTimerFinishedListener) to be called when the time has elapsed after startTimer() has been called. Tap action can be received via setOnClickListener(OnClickListener) and can be used to cancel the timer via stopTimer() method.

Alternatively, this layout can be used to show indeterminate progress by calling setIndeterminate(boolean) method.

Summary

Nested classes

interface CircularProgressLayout.OnTimerFinishedListener

Interface to implement for listening to onTimerFinished(CircularProgressLayout) event. 

Inherited constants

From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

CircularProgressLayout(Context context)
CircularProgressLayout(Context context, AttributeSet attrs)
CircularProgressLayout(Context context, AttributeSet attrs, int defStyleAttr)
CircularProgressLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes)

Public methods

int getBackgroundColor()

Returns the background color of the CircularProgressDrawable.

int[] getColorSchemeColors()

Returns the color scheme colors of the progress drawable

CircularProgressLayout.OnTimerFinishedListener getOnTimerFinishedListener()

Returns the CircularProgressLayout.OnTimerFinishedListener that is registered to this layout.

CircularProgressDrawable getProgressDrawable()

Returns the CircularProgressDrawable used as background of this layout.

float getStartingRotation()

Returns the starting rotation of the progress drawable.

float getStrokeWidth()

Returns the stroke width of the progress drawable in pixels.

long getTotalTime()

Returns the total time in milliseconds for the timer to countdown to.

boolean isIndeterminate()

Returns if progress is showing as an indeterminate spinner.

boolean isTimerRunning()

Returns if the timer is running.

void setBackgroundColor(int color)

Sets the background color of the CircularProgressDrawable, which is drawn as a circle inside the progress drawable.

void setColorSchemeColors(int... colors)

Sets the color scheme colors of the progress drawable, which is equivalent to calling setColorSchemeColors(int) method on background drawable of this layout.

void setIndeterminate(boolean indeterminate)

Sets if progress should be shown as an indeterminate spinner.

void setOnTimerFinishedListener(CircularProgressLayout.OnTimerFinishedListener listener)

Sets the CircularProgressLayout.OnTimerFinishedListener to be notified when timer countdown is finished.

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 startTimer()

Starts the timer countdown.

void stopTimer()

Stops the timer countdown.

Protected methods

void onDetachedFromWindow()
void onLayout(boolean changed, int left, int top, int right, int bottom)

Inherited methods

From class android.widget.FrameLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

CircularProgressLayout

added in version 26.1.0
CircularProgressLayout (Context context)

Parameters
context Context

CircularProgressLayout

added in version 26.1.0
CircularProgressLayout (Context context, 
                AttributeSet attrs)

Parameters
context Context

attrs AttributeSet

CircularProgressLayout

added in version 26.1.0
CircularProgressLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

CircularProgressLayout

added in version 26.1.0
CircularProgressLayout (Context context, 
                AttributeSet attrs, 
                int defStyleAttr, 
                int defStyleRes)

Parameters
context Context

attrs AttributeSet

defStyleAttr int

defStyleRes int

Public methods

getBackgroundColor

added in version 26.1.0
int getBackgroundColor ()

Returns the background color of the CircularProgressDrawable.

Returns
int an ARGB color

getColorSchemeColors

added in version 26.1.0
int[] getColorSchemeColors ()

Returns the color scheme colors of the progress drawable

Returns
int[] list of ARGB colors

getOnTimerFinishedListener

added in version 26.1.0
CircularProgressLayout.OnTimerFinishedListener getOnTimerFinishedListener ()

Returns the CircularProgressLayout.OnTimerFinishedListener that is registered to this layout.

Returns
CircularProgressLayout.OnTimerFinishedListener registered CircularProgressLayout.OnTimerFinishedListener

getProgressDrawable

added in version 26.1.0
CircularProgressDrawable getProgressDrawable ()

Returns the CircularProgressDrawable used as background of this layout.

Returns
CircularProgressDrawable CircularProgressDrawable

getStartingRotation

added in version 26.1.0
float getStartingRotation ()

Returns the starting rotation of the progress drawable.

Returns
float starting rotation from [0..1]

getStrokeWidth

added in version 26.1.0
float getStrokeWidth ()

Returns the stroke width of the progress drawable in pixels.

Returns
float stroke width in pixels

getTotalTime

added in version 26.1.0
long getTotalTime ()

Returns the total time in milliseconds for the timer to countdown to.

Returns
long total time in milliseconds

isIndeterminate

added in version 26.1.0
boolean isIndeterminate ()

Returns if progress is showing as an indeterminate spinner.

Returns
boolean true if indeterminate spinner is shown, false otherwise.

isTimerRunning

added in version 26.1.0
boolean isTimerRunning ()

Returns if the timer is running.

Returns
boolean true if the timer is running, false otherwise

setBackgroundColor

void setBackgroundColor (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
color int: an ARGB color

setColorSchemeColors

added in version 26.1.0
void setColorSchemeColors (int... colors)

Sets the color scheme colors of the progress drawable, which is equivalent to calling setColorSchemeColors(int) method on background drawable of this layout.

Parameters
colors int: list of ARGB colors

setIndeterminate

added in version 26.1.0
void setIndeterminate (boolean indeterminate)

Sets if progress should be shown as an indeterminate spinner.

Parameters
indeterminate boolean: true if indeterminate spinner should be shown, false otherwise.

setOnTimerFinishedListener

added in version 26.1.0
void setOnTimerFinishedListener (CircularProgressLayout.OnTimerFinishedListener listener)

Sets the CircularProgressLayout.OnTimerFinishedListener to be notified when timer countdown is finished.

Parameters
listener CircularProgressLayout.OnTimerFinishedListener: CircularProgressLayout.OnTimerFinishedListener to be notified, or null to clear

setStartingRotation

added in version 26.1.0
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
rotation float: starting rotation from [0..1]

setStrokeWidth

added in version 26.1.0
void setStrokeWidth (float strokeWidth)

Sets the stroke width of the progress drawable in pixels.

Parameters
strokeWidth float: stroke width in pixels

setTotalTime

added in version 26.1.0
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
totalTime long: total time in milliseconds

startTimer

added in version 26.1.0
void startTimer ()

Starts the timer countdown. Once the countdown is finished, if there is an CircularProgressLayout.OnTimerFinishedListener registered by setOnTimerFinishedListener(OnTimerFinishedListener) method, its onTimerFinished(CircularProgressLayout) method is called. If this method is called while there is already a running timer, it will restart the timer.

stopTimer

added in version 26.1.0
void stopTimer ()

Stops the timer countdown. If there is no timer running, calling this method will not do anything.

Protected methods

onDetachedFromWindow

void onDetachedFromWindow ()

onLayout

void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

Parameters
changed boolean

left int

top int

right int

bottom int