DeterminateDrawable
public
final
class
DeterminateDrawable
extends Drawable
implements
Animatable2Compat
java.lang.Object | ||
↳ | android.graphics.drawable.Drawable | |
↳ | com.google.android.material.progressindicator.DeterminateDrawable<S extends com.google.android.material.progressindicator.BaseProgressIndicatorSpec> |
This class draws the graphics for determinate mode.
Summary
Public methods | |
---|---|
void
|
addSpringAnimationEndListener(DynamicAnimation.OnAnimationEndListener listener)
|
void
|
clearAnimationCallbacks()
Unregisters all |
static
DeterminateDrawable<CircularProgressIndicatorSpec>
|
createCircularDrawable(Context context, CircularProgressIndicatorSpec spec)
Creates an instance of |
static
DeterminateDrawable<LinearProgressIndicatorSpec>
|
createLinearDrawable(Context context, LinearProgressIndicatorSpec spec)
Creates an instance of |
void
|
draw(Canvas canvas)
|
int
|
getAlpha()
|
int
|
getIntrinsicHeight()
|
int
|
getIntrinsicWidth()
|
int
|
getOpacity()
|
boolean
|
hideNow()
Hides the drawable immediately without triggering animation callbacks. |
boolean
|
isHiding()
|
boolean
|
isRunning()
|
boolean
|
isShowing()
|
void
|
jumpToCurrentState()
Skips the animation of changing indicator length, directly displays the target progress. |
void
|
registerAnimationCallback(Animatable2Compat.AnimationCallback callback)
Registers a new |
void
|
removeSpringAnimationEndListener(DynamicAnimation.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
|
start()
The drawable will start the main animation without show animator. |
void
|
stop()
The drawable will stop the main animation without hide animator. |
boolean
|
unregisterAnimationCallback(Animatable2Compat.AnimationCallback callback)
Unregisters an |
Protected methods | |
---|---|
boolean
|
onLevelChange(int level)
When progress is updated, it changes the level of drawable's level and calls this method afterward. |
Inherited methods | |
---|---|
Public methods
addSpringAnimationEndListener
public void addSpringAnimationEndListener (DynamicAnimation.OnAnimationEndListener listener)
Parameters | |
---|---|
listener |
DynamicAnimation.OnAnimationEndListener |
clearAnimationCallbacks
public void clearAnimationCallbacks ()
Unregisters all AnimationCallback
from this drawable.
createCircularDrawable
public static DeterminateDrawable<CircularProgressIndicatorSpec> createCircularDrawable (Context context, CircularProgressIndicatorSpec spec)
Creates an instance of DeterminateDrawable
for CircularProgressIndicator
with
CircularProgressIndicatorSpec
.
Parameters | |
---|---|
context |
Context : The current context. |
spec |
CircularProgressIndicatorSpec : The spec for the circular indicator.
|
Returns | |
---|---|
DeterminateDrawable<CircularProgressIndicatorSpec> |
createLinearDrawable
public static DeterminateDrawable<LinearProgressIndicatorSpec> createLinearDrawable (Context context, LinearProgressIndicatorSpec spec)
Creates an instance of DeterminateDrawable
for LinearProgressIndicator
with
LinearProgressIndicatorSpec
.
Parameters | |
---|---|
context |
Context : The current context. |
spec |
LinearProgressIndicatorSpec : The spec for the linear indicator.
|
Returns | |
---|---|
DeterminateDrawable<LinearProgressIndicatorSpec> |
draw
public void draw (Canvas canvas)
Parameters | |
---|---|
canvas |
Canvas |
getAlpha
public int getAlpha ()
Returns | |
---|---|
int |
getIntrinsicHeight
public int getIntrinsicHeight ()
Returns | |
---|---|
int |
getIntrinsicWidth
public int getIntrinsicWidth ()
Returns | |
---|---|
int |
getOpacity
public int getOpacity ()
Returns | |
---|---|
int |
hideNow
public boolean hideNow ()
Hides the drawable immediately without triggering animation callbacks.
Returns | |
---|---|
boolean |
isHiding
public boolean isHiding ()
Returns | |
---|---|
boolean |
isRunning
public boolean isRunning ()
Returns | |
---|---|
boolean |
isShowing
public boolean isShowing ()
Returns | |
---|---|
boolean |
jumpToCurrentState
public void jumpToCurrentState ()
Skips the animation of changing indicator length, directly displays the target progress.
registerAnimationCallback
public void registerAnimationCallback (Animatable2Compat.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 | |
---|---|
callback |
Animatable2Compat.AnimationCallback : A new AnimationCallback to register. |
removeSpringAnimationEndListener
public void removeSpringAnimationEndListener (DynamicAnimation.OnAnimationEndListener listener)
Parameters | |
---|---|
listener |
DynamicAnimation.OnAnimationEndListener |
setAlpha
public void setAlpha (int alpha)
Parameters | |
---|---|
alpha |
int |
setColorFilter
public void setColorFilter (ColorFilter colorFilter)
Parameters | |
---|---|
colorFilter |
ColorFilter |
setVisible
public boolean setVisible (boolean visible, boolean restart)
Parameters | |
---|---|
visible |
boolean |
restart |
boolean |
Returns | |
---|---|
boolean |
setVisible
public boolean setVisible (boolean visible, boolean restart, boolean animate)
Changes the visibility with/without triggering the animation callbacks.
Parameters | |
---|---|
visible |
boolean : Whether to make the drawable visible. |
restart |
boolean : Whether to force starting the animation from the beginning. |
animate |
boolean : Whether to change the visibility with animation. |
Returns | |
---|---|
boolean |
true , if the visibility changes or will change after the animation; false , otherwise. |
See also:
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 (Animatable2Compat.AnimationCallback callback)
Unregisters an AnimationCallback
from this drawable.
Parameters | |
---|---|
callback |
Animatable2Compat.AnimationCallback : 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 | |
---|---|
level |
int : New progress level.
|
Returns | |
---|---|
boolean |