public class FrameSequenceDrawable extends Drawable implements Animatable, Runnable
Modifier and Type | Class and Description |
---|---|
static interface |
FrameSequenceDrawable.BitmapProvider |
static interface |
FrameSequenceDrawable.OnFinishedListener |
Drawable.Callback, Drawable.ConstantState
Modifier and Type | Field and Description |
---|---|
static int |
LOOP_DEFAULT
Use loop count stored in source data, or LOOP_ONCE if not present.
|
static int |
LOOP_INF
Loop continuously.
|
static int |
LOOP_ONCE
Loop only once.
|
Constructor and Description |
---|
FrameSequenceDrawable(FrameSequence frameSequence) |
FrameSequenceDrawable(FrameSequence frameSequence,
FrameSequenceDrawable.BitmapProvider bitmapProvider) |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
Marks the drawable as permanently recycled (and thus unusable), and releases any owned
Bitmaps drawable to its BitmapProvider, if attached.
|
void |
draw(Canvas canvas)
Draw in its bounds (set via setBounds) respecting optional effects such
as alpha (set via setAlpha) and color filter (set via setColorFilter).
|
protected void |
finalize()
Called by the garbage collector on an object when garbage collection
determines that there are no more references to the object.
|
int |
getIntrinsicHeight()
Returns the drawable's intrinsic height.
|
int |
getIntrinsicWidth()
Returns the drawable's intrinsic width.
|
int |
getOpacity()
Return the opacity/transparency of this Drawable.
|
boolean |
isDestroyed() |
boolean |
isRunning()
Indicates whether the animation is running.
|
void |
run()
When an object implementing interface
Runnable is used
to create a thread, starting the thread causes the object's
run method to be called in that separately executing
thread. |
void |
setAlpha(int alpha)
Specify an alpha value for the drawable. 0 means fully transparent, and
255 means fully opaque.
|
void |
setCircleMaskEnabled(boolean circleMaskEnabled)
Pass true to mask the shape of the animated drawing content to a circle.
|
void |
setColorFilter(ColorFilter colorFilter)
Specify an optional color filter for the drawable.
|
void |
setFilterBitmap(boolean filter)
Set to true to have the drawable filter its bitmaps with bilinear
sampling when they are scaled or rotated.
|
void |
setLoopBehavior(int loopBehavior)
Define looping behavior of frame sequence.
|
void |
setOnFinishedListener(FrameSequenceDrawable.OnFinishedListener onFinishedListener)
Register a callback to be invoked when a FrameSequenceDrawable finishes looping.
|
boolean |
setVisible(boolean visible,
boolean restart)
Set whether this Drawable is visible.
|
void |
start()
Starts the drawable's animation.
|
void |
stop()
Stops the drawable's animation.
|
void |
unscheduleSelf(Runnable what)
Use the current
Drawable.Callback implementation to have this Drawable
unscheduled. |
applyTheme, canApplyTheme, clearColorFilter, clearMutated, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getAlpha, getBounds, getCallback, getChangingConfigurations, getColorFilter, getConstantState, getCurrent, getDirtyBounds, getHotspotBounds, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOpticalInsets, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isProjected, isStateful, isVisible, jumpToCurrentState, mutate, obtainAttributes, onBoundsChange, onLayoutDirectionChanged, onLevelChange, onStateChange, parseTintMode, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, setXfermode
public static final int LOOP_ONCE
public static final int LOOP_INF
public static final int LOOP_DEFAULT
public FrameSequenceDrawable(FrameSequence frameSequence)
public FrameSequenceDrawable(FrameSequence frameSequence, FrameSequenceDrawable.BitmapProvider bitmapProvider)
public void setOnFinishedListener(FrameSequenceDrawable.OnFinishedListener onFinishedListener)
setLoopBehavior(int)
public void setLoopBehavior(int loopBehavior)
public final void setCircleMaskEnabled(boolean circleMaskEnabled)
The masking circle will be the largest circle contained in the Drawable's bounds. Masking is done with BitmapShader, incurring minimal additional draw cost.
public boolean isDestroyed()
public void destroy()
protected void finalize() throws Throwable
Object
finalize
method to dispose of
system resources or to perform other cleanup.
The general contract of finalize
is that it is invoked
if and when the JavaTM virtual
machine has determined that there is no longer any
means by which this object can be accessed by any thread that has
not yet died, except as a result of an action taken by the
finalization of some other object or class which is ready to be
finalized. The finalize
method may take any action, including
making this object available again to other threads; the usual purpose
of finalize
, however, is to perform cleanup actions before
the object is irrevocably discarded. For example, the finalize method
for an object that represents an input/output connection might perform
explicit I/O transactions to break the connection before the object is
permanently discarded.
The finalize
method of class Object
performs no
special action; it simply returns normally. Subclasses of
Object
may override this definition.
The Java programming language does not guarantee which thread will
invoke the finalize
method for any given object. It is
guaranteed, however, that the thread that invokes finalize will not
be holding any user-visible synchronization locks when finalize is
invoked. If an uncaught exception is thrown by the finalize method,
the exception is ignored and finalization of that object terminates.
After the finalize
method has been invoked for an object, no
further action is taken until the Java virtual machine has again
determined that there is no longer any means by which this object can
be accessed by any thread that has not yet died, including possible
actions by other objects or classes which are ready to be finalized,
at which point the object may be discarded.
The finalize
method is never invoked more than once by a Java
virtual machine for any given object.
Any exception thrown by the finalize
method causes
the finalization of this object to be halted, but is otherwise
ignored.
public void draw(Canvas canvas)
Drawable
public void run()
Runnable
Runnable
is used
to create a thread, starting the thread causes the object's
run
method to be called in that separately executing
thread.
The general contract of the method run
is that it may
take any action whatsoever.
run
in interface Runnable
Thread.run()
public void start()
Animatable
start
in interface Animatable
public void stop()
Animatable
stop
in interface Animatable
public boolean isRunning()
Animatable
isRunning
in interface Animatable
public void unscheduleSelf(Runnable what)
Drawable
Drawable.Callback
implementation to have this Drawable
unscheduled. Does nothing if there is no Callback attached to the
Drawable.unscheduleSelf
in class Drawable
what
- The runnable that you no longer want called.Drawable.Callback.unscheduleDrawable(android.graphics.drawable.Drawable, java.lang.Runnable)
public boolean setVisible(boolean visible, boolean restart)
Drawable
setVisible
in class Drawable
visible
- Set to true if visible, false if not.restart
- You can supply true here to force the drawable to behave
as if it has just become visible, even if it had last
been set visible. Used for example to force animations
to restart.public void setFilterBitmap(boolean filter)
Drawable
This can improve appearance when bitmaps are rotated. If the drawable does not use bitmaps, this call is ignored.
setFilterBitmap
in class Drawable
Drawable.isFilterBitmap()
,
Paint.setFilterBitmap(boolean);
public void setAlpha(int alpha)
Drawable
public void setColorFilter(ColorFilter colorFilter)
Drawable
If a Drawable has a ColorFilter, each output pixel of the Drawable's drawing contents will be modified by the color filter before it is blended onto the render target of a Canvas.
Pass null
to remove any existing color filter.
Note: Setting a non-null
color
filter disables tint
.
setColorFilter
in class Drawable
colorFilter
- The color filter to apply, or null
to remove the
existing color filterpublic int getIntrinsicWidth()
Drawable
Intrinsic width is the width at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic width, such as a solid color, this method returns -1.
getIntrinsicWidth
in class Drawable
public int getIntrinsicHeight()
Drawable
Intrinsic height is the height at which the drawable would like to be laid out, including any inherent padding. If the drawable has no intrinsic height, such as a solid color, this method returns -1.
getIntrinsicHeight
in class Drawable
public int getOpacity()
Drawable
PixelFormat
:
PixelFormat.UNKNOWN
,
PixelFormat.TRANSLUCENT
,
PixelFormat.TRANSPARENT
, or
PixelFormat.OPAQUE
.
An OPAQUE drawable is one that draws all all content within its bounds, completely covering anything behind the drawable. A TRANSPARENT drawable is one that draws nothing within its bounds, allowing everything behind it to show through. A TRANSLUCENT drawable is a drawable in any other state, where the drawable will draw some, but not all, of the content within its bounds and at least some content behind the drawable will be visible. If the visibility of the drawable's contents cannot be determined, the safest/best return value is TRANSLUCENT.
Generally a Drawable should be as conservative as possible with the
value it returns. For example, if it contains multiple child drawables
and only shows one of them at a time, if only one of the children is
TRANSLUCENT and the others are OPAQUE then TRANSLUCENT should be
returned. You can use the method Drawable.resolveOpacity(int, int)
to perform a
standard reduction of two opacities to the appropriate single output.
Note that the returned value does not necessarily take into account a
custom alpha or color filter that has been applied by the client through
the Drawable.setAlpha(int)
or Drawable.setColorFilter(android.graphics.ColorFilter)
methods. Some subclasses,
such as BitmapDrawable
, ColorDrawable
, and GradientDrawable
,
do account for the value of Drawable.setAlpha(int)
, but the general behavior is dependent
upon the implementation of the subclass.
getOpacity
in class Drawable
PixelFormat