# DeterminateDrawable

[View Source](https://github.com/material-components/material-components-android/blob/1.14.0/lib/java/com/google/android/material/progressindicator/DeterminateDrawable.java)

*** ** * ** ***


```
public final class DeterminateDrawable<S extends BaseProgressIndicatorSpec>
```

<br />

*** ** * ** ***

This class draws the graphics for determinate mode.

## Summary

| ### Public methods |
|---|---|
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#addSpringAnimationEndListener(DynamicAnimation.OnAnimationEndListener)(OnAnimationEndListener listener)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#clearAnimationCallbacks()()` Unregisters all `AnimationCallback` from this drawable. |
| `static https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable<https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicatorSpec>` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#createCircularDrawable(Context,com.google.android.material.progressindicator.CircularProgressIndicatorSpec)( Context context, https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicatorSpec spec )` Creates an instance of `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable` for `https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicator` with `https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicatorSpec`. |
| `static https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable<https://developer.android.com/reference/com/google/android/material/progressindicator/LinearProgressIndicatorSpec>` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#createLinearDrawable(Context,com.google.android.material.progressindicator.LinearProgressIndicatorSpec)(Context context, https://developer.android.com/reference/com/google/android/material/progressindicator/LinearProgressIndicatorSpec spec)` Creates an instance of `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable` for `https://developer.android.com/reference/com/google/android/material/progressindicator/LinearProgressIndicator` with `https://developer.android.com/reference/com/google/android/material/progressindicator/LinearProgressIndicatorSpec`. |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#draw(Canvas)(Canvas canvas)` |
| `int` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#getAlpha()()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#getIntrinsicHeight()()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#getIntrinsicWidth()()` |
| `int` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#getOpacity()()` |
| `SpringForce` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#getSpringForce()()` Returns the spring force of the spring animation for the progress. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#hideNow()()` Hides the drawable immediately without triggering animation callbacks. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#isHiding()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#isRunning()()` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#isShowing()()` |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#jumpToCurrentState()()` Skips the animation of changing indicator length, directly displays the target progress. |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#registerAnimationCallback(AnimationCallback)(AnimationCallback callback)` Registers a new `AnimationCallback` to this drawable. |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#removeSpringAnimationEndListener(DynamicAnimation.OnAnimationEndListener)(OnAnimationEndListener listener)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#setAlpha(int)(int alpha)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#setColorFilter(ColorFilter)(ColorFilter colorFilter)` |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#setSpringForce(SpringForce)(SpringForce spring)` Sets the spring force of the spring animation for the progress. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#setVisible(boolean,boolean)(boolean visible, boolean restart)` |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#setVisible(boolean,boolean,boolean)(boolean visible, boolean restart, boolean animate)` Changes the visibility with/without triggering the animation callbacks. |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#start()()` The drawable will start the main animation without show animator. |
| `void` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#stop()()` The drawable will stop the main animation without hide animator. |
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#unregisterAnimationCallback(AnimationCallback)(AnimationCallback callback)` Unregisters an `AnimationCallback` from this drawable. |

| ### Protected methods |
|---|---|
| `boolean` | `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable#onLevelChange(int)(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<CircularProgressIndicatorSpec> createCircularDrawable(
    Context context,
    CircularProgressIndicatorSpec spec
)
```

Creates an instance of `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable` for `https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicator` with `https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicatorSpec`.

| Parameters |
|---|---|
| `Context context` | The current context. |
| `https://developer.android.com/reference/com/google/android/material/progressindicator/CircularProgressIndicatorSpec spec` | The spec for the circular indicator. |

### createLinearDrawable

```
public static DeterminateDrawable<LinearProgressIndicatorSpec> createLinearDrawable(Context context, LinearProgressIndicatorSpec spec)
```

Creates an instance of `https://developer.android.com/reference/com/google/android/material/progressindicator/DeterminateDrawable` for `https://developer.android.com/reference/com/google/android/material/progressindicator/LinearProgressIndicator` with `https://developer.android.com/reference/com/google/android/material/progressindicator/LinearProgressIndicatorSpec`.

| Parameters |
|---|---|
| `Context context` | The current context. |
| `https://developer.android.com/reference/com/google/android/material/progressindicator/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()
```

### getSpringForce

```
public SpringForce getSpringForce()
```

Returns the spring force of the spring animation for the progress.

### 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. |

| See also |
|---|---|
| `https://developer.android.com/reference/AnimationCallback#onAnimationStart(Drawable)` |   |
| `https://developer.android.com/reference/AnimationCallback#onAnimationEnd(Drawable)` |   |

### removeSpringAnimationEndListener

```
public void removeSpringAnimationEndListener(OnAnimationEndListener listener)
```

### setAlpha

```
public void setAlpha(int alpha)
```

### setColorFilter

```
public void setColorFilter(ColorFilter colorFilter)
```

### setSpringForce

```
public void setSpringForce(SpringForce spring)
```

Sets the spring force of the spring animation for the progress.

### 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. |