CircularProgressLayout

public class 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

CircularProgressLayout.OnTimerFinishedListener

Interface to implement for listening to onTimerFinished event.

Public constructors

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

Public methods

@ColorInt int

Returns the background color of the CircularProgressDrawable.

int[]

Returns the color scheme colors of the progress drawable

@Nullable CircularProgressLayout.OnTimerFinishedListener

Returns the OnTimerFinishedListener that is registered to this layout.

@NonNull CircularProgressDrawable

Returns the CircularProgressDrawable used as background of this layout.

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.

@Override void

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 method on background drawable of this layout.

void
setIndeterminate(boolean indeterminate)

Sets if progress should be shown as an indeterminate spinner.

void

Sets the 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

Starts the timer countdown.

void

Stops the timer countdown.