Added in API level 1

Callback


interface Callback
android.graphics.drawable.Drawable.Callback

Implement this interface if you want to create an animated drawable that extends Drawable. Upon retrieving a drawable, use Drawable#setCallback(android.graphics.drawable.Drawable.Callback) to supply your implementation of the interface to the drawable; it uses this interface to schedule and execute animation changes.

Summary

Public methods
abstract Unit

Called when the drawable needs to be redrawn.

abstract Unit
scheduleDrawable(who: Drawable, what: Runnable, when: Long)

A Drawable can call this to schedule the next frame of its animation.

abstract Unit

A Drawable can call this to unschedule an action previously scheduled with scheduleDrawable.

Public methods

invalidateDrawable

Added in API level 1
abstract fun invalidateDrawable(who: Drawable): Unit

Called when the drawable needs to be redrawn. A view at this point should invalidate itself (or at least the part of itself where the drawable appears).

Parameters
who Drawable: The drawable that is requesting the update. This value cannot be null.

scheduleDrawable

Added in API level 1
abstract fun scheduleDrawable(
    who: Drawable,
    what: Runnable,
    when: Long
): Unit

A Drawable can call this to schedule the next frame of its animation. An implementation can generally simply call android.os.Handler#postAtTime(Runnable, Object, long) with the parameters (what, who, when) to perform the scheduling.

Parameters
who Drawable: The drawable being scheduled. This value cannot be null.
what Runnable: The action to execute. This value cannot be null.
when Long: The time (in milliseconds) to run. The timebase is android.os.SystemClock#uptimeMillis

unscheduleDrawable

Added in API level 1
abstract fun unscheduleDrawable(
    who: Drawable,
    what: Runnable
): Unit

A Drawable can call this to unschedule an action previously scheduled with scheduleDrawable. An implementation can generally simply call android.os.Handler#removeCallbacks(Runnable, Object) with the parameters (what, who) to unschedule the drawable.

Parameters
who Drawable: The drawable being unscheduled. This value cannot be null.
what Runnable: The action being unscheduled. This value cannot be null.