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(
    @NonNull Context context,
    @NonNull AttributeSet attrs
)
CircularProgressLayout(
    @NonNull Context context,
    @NonNull AttributeSet attrs,
    @NonNull int defStyleAttr
)
CircularProgressLayout(
    @NonNull Context context,
    @NonNull AttributeSet attrs,
    @NonNull int defStyleAttr,
    @NonNull int defStyleRes
)

Public methods

@ColorInt @NonNull int

Returns the background color of the CircularProgressDrawable.

@NonNull 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.

@NonNull float

Returns the starting rotation of the progress drawable.

@NonNull float

Returns the stroke width of the progress drawable in pixels.

@NonNull long

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

@NonNull boolean

Returns if progress is showing as an indeterminate spinner.

@NonNull boolean

Returns if the timer is running.

@Override @NonNull void

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

@NonNull void

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

@NonNull void
setIndeterminate(@NonNull boolean indeterminate)

Sets if progress should be shown as an indeterminate spinner.

@NonNull void

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

@NonNull void
setStartingRotation(@NonNull float rotation)

Sets the starting rotation for the progress drawable to start from.

@NonNull void
setStrokeWidth(@NonNull float strokeWidth)

Sets the stroke width of the progress drawable in pixels.

@NonNull void
setTotalTime(@NonNull long totalTime)

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

@NonNull void

Starts the timer countdown.

@NonNull void

Stops the timer countdown.