DeterminateDrawable

public final class DeterminateDrawable<S extends BaseProgressIndicatorSpec>


This class draws the graphics for determinate mode.

Summary

Public methods

void
addSpringAnimationEndListener(OnAnimationEndListener listener)
void

Unregisters all AnimationCallback from this drawable.

static DeterminateDrawable<CircularProgressIndicatorSpec>
createCircularDrawable(
    Context context,
    CircularProgressIndicatorSpec spec
)

Creates an instance of DeterminateDrawable for CircularProgressIndicator with CircularProgressIndicatorSpec.

static DeterminateDrawable<LinearProgressIndicatorSpec>

Creates an instance of DeterminateDrawable for LinearProgressIndicator with LinearProgressIndicatorSpec.

void
draw(Canvas canvas)
int
int
int
int
boolean

Hides the drawable immediately without triggering animation callbacks.

boolean
boolean
boolean
void

Skips the animation of changing indicator length, directly displays the target progress.

void
registerAnimationCallback(AnimationCallback callback)

Registers a new AnimationCallback to this drawable.

void
removeSpringAnimationEndListener(OnAnimationEndListener listener)
void
setAlpha(int alpha)
void
setColorFilter(ColorFilter colorFilter)
boolean
setVisible(boolean visible, boolean restart)
boolean
setVisible(boolean visible, boolean restart, boolean animate)

Changes the visibility with/without triggering the animation callbacks.

void

The drawable will start the main animation without show animator.

void

The drawable will stop the main animation without hide animator.

boolean
unregisterAnimationCallback(AnimationCallback callback)

Unregisters an AnimationCallback from this drawable.

Protected methods

boolean
onLevelChange(int level)

When progress is updated, it changes the level of drawable's level and calls this method afterward.

Public methods

addSpringAnimationEndListener

public void addSpringAnimationEndListener(OnAnimationEndListener listener)

clearAnimationCallbacks

public void clearAnimationCallbacks()

Unregisters all AnimationCallback from this drawable.

createCircularDrawable

public static DeterminateDrawable<CircularProgressIndicatorSpeccreateCircularDrawable(
    Context context,
    CircularProgressIndicatorSpec spec
)

Creates an instance of DeterminateDrawable for CircularProgressIndicator with CircularProgressIndicatorSpec.

Parameters
Context context

The current context.

CircularProgressIndicatorSpec spec

The spec for the circular indicator.

createLinearDrawable

public static DeterminateDrawable<LinearProgressIndicatorSpeccreateLinearDrawable(Context context, LinearProgressIndicatorSpec spec)

Creates an instance of DeterminateDrawable for LinearProgressIndicator with LinearProgressIndicatorSpec.

Parameters
Context context

The current context.

LinearProgressIndicatorSpec spec

The spec for the linear indicator.

draw

public void draw(Canvas canvas)

getAlpha

public int getAlpha()

getIntrinsicHeight

public int getIntrinsicHeight()

getIntrinsicWidth

public int getIntrinsicWidth()

getOpacity

public int getOpacity()

hideNow

public boolean hideNow()

Hides the drawable immediately without triggering animation callbacks.

isHiding

public boolean isHiding()

isRunning

public boolean isRunning()

isShowing

public boolean isShowing()

jumpToCurrentState

public void jumpToCurrentState()

Skips the animation of changing indicator length, directly displays the target progress.

registerAnimationCallback

public void registerAnimationCallback(AnimationCallback callback)

Registers a new AnimationCallback to this drawable. The onAnimationStart() will be called at the start of show animation, or at the moment this drawable is shown, if there's no show animation is used. The onAnimationEnd() will be called at the end of the hide animation, or at the moment this drawable is hidden, if there's no hide animation is used.

Parameters
AnimationCallback callback

A new AnimationCallback to register.

removeSpringAnimationEndListener

public void removeSpringAnimationEndListener(OnAnimationEndListener listener)

setAlpha

public void setAlpha(int alpha)

setColorFilter

public void setColorFilter(ColorFilter colorFilter)

setVisible

public boolean setVisible(boolean visible, boolean restart)

setVisible

public boolean setVisible(boolean visible, boolean restart, boolean animate)

Changes the visibility with/without triggering the animation callbacks.

Parameters
boolean visible

Whether to make the drawable visible.

boolean restart

Whether to force starting the animation from the beginning.

boolean animate

Whether to change the visibility with animation.

Returns
boolean

true, if the visibility changes or will change after the animation; false, otherwise.

start

public void start()

The drawable will start the main animation without show animator.

stop

public void stop()

The drawable will stop the main animation without hide animator.

unregisterAnimationCallback

public boolean unregisterAnimationCallback(AnimationCallback callback)

Unregisters an AnimationCallback from this drawable.

Parameters
AnimationCallback callback

AnimationCallback to unregister.

Returns
boolean

true, if callback is successfully registered; false, otherwise.

Protected methods

onLevelChange

protected boolean onLevelChange(int level)

When progress is updated, it changes the level of drawable's level and calls this method afterward. It sets the new progress value to animation and starts the animation.

Parameters
int level

New progress level.