CircularProgressLayout
class CircularProgressLayout : FrameLayout
| kotlin.Any | ||||
| ↳ | 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 |
|---|
|
Interface to implement for listening to |
Public constructors |
|---|
CircularProgressLayout(context: Context!) |
CircularProgressLayout(context: Context!, attrs: AttributeSet!) |
CircularProgressLayout( |
CircularProgressLayout( |
Public functions |
|
|---|---|
@ColorInt Int |
Returns the background color of the |
IntArray<Int>! |
Returns the color scheme colors of the progress drawable |
CircularProgressLayout.OnTimerFinishedListener? |
Returns the |
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. |
Unit |
setBackgroundColor(color: @ColorInt Int)Sets the background color of the |
Unit |
setColorSchemeColors(colors: IntArray!)Sets the color scheme colors of the progress drawable, which is equivalent to calling |
Unit |
setIndeterminate(indeterminate: Boolean)Sets if progress should be shown as an indeterminate spinner. |
Unit |
Sets the |
Unit |
setStartingRotation(rotation: Float)Sets the starting rotation for the progress drawable to start from. |
Unit |
setStrokeWidth(strokeWidth: Float)Sets the stroke width of the progress drawable in pixels. |
Unit |
setTotalTime(totalTime: Long)Sets the total time in milliseconds for the timer to countdown to. |
Unit |
Starts the timer countdown. |
Unit |
Stops the timer countdown. |
Inherited Constants |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Public constructors
CircularProgressLayout
CircularProgressLayout(context: Context!, attrs: AttributeSet!)
CircularProgressLayout
CircularProgressLayout(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int
)
CircularProgressLayout
CircularProgressLayout(
context: Context!,
attrs: AttributeSet!,
defStyleAttr: Int,
defStyleRes: Int
)
Public functions
getBackgroundColor
fun getBackgroundColor(): @ColorInt Int
Returns the background color of the CircularProgressDrawable.
getColorSchemeColors
fun getColorSchemeColors(): IntArray<Int>!
Returns the color scheme colors of the progress drawable
getOnTimerFinishedListener
fun getOnTimerFinishedListener(): CircularProgressLayout.OnTimerFinishedListener?
Returns the OnTimerFinishedListener that is registered to this layout.
| Returns | |
|---|---|
CircularProgressLayout.OnTimerFinishedListener? |
registered |
getProgressDrawable
fun getProgressDrawable(): CircularProgressDrawable
Returns the CircularProgressDrawable used as background of this layout.
getStartingRotation
fun getStartingRotation(): Float
Returns the starting rotation of the progress drawable.
| Returns | |
|---|---|
Float |
starting rotation from [0..1] |
getStrokeWidth
fun getStrokeWidth(): Float
Returns the stroke width of the progress drawable in pixels.
| Returns | |
|---|---|
Float |
stroke width in pixels |
getTotalTime
fun getTotalTime(): Long
Returns the total time in milliseconds for the timer to countdown to.
| Returns | |
|---|---|
Long |
total time in milliseconds |
isIndeterminate
fun isIndeterminate(): Boolean
Returns if progress is showing as an indeterminate spinner.
| Returns | |
|---|---|
Boolean |
|
isTimerRunning
fun isTimerRunning(): Boolean
Returns if the timer is running.
| Returns | |
|---|---|
Boolean |
|
setBackgroundColor
fun setBackgroundColor(color: @ColorInt Int): Unit
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.
setColorSchemeColors
fun setColorSchemeColors(colors: IntArray!): Unit
Sets the color scheme colors of the progress drawable, which is equivalent to calling setColorSchemeColors method on background drawable of this layout.
| Parameters | |
|---|---|
colors: IntArray! |
list of ARGB colors |
setIndeterminate
fun setIndeterminate(indeterminate: Boolean): Unit
Sets if progress should be shown as an indeterminate spinner.
| Parameters | |
|---|---|
indeterminate: Boolean |
|
setOnTimerFinishedListener
fun setOnTimerFinishedListener(
listener: CircularProgressLayout.OnTimerFinishedListener?
): Unit
Sets the OnTimerFinishedListener to be notified when timer countdown is finished.
| Parameters | |
|---|---|
listener: CircularProgressLayout.OnTimerFinishedListener? |
|
setStartingRotation
fun setStartingRotation(rotation: Float): Unit
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
fun setStrokeWidth(strokeWidth: Float): Unit
Sets the stroke width of the progress drawable in pixels.
| Parameters | |
|---|---|
strokeWidth: Float |
stroke width in pixels |
setTotalTime
fun setTotalTime(totalTime: Long): Unit
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
fun startTimer(): Unit
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.