public class GifDrawable extends Drawable implements com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback, Animatable
Drawable
that plays the frames of an animated GIF.Drawable.Callback, Drawable.ConstantState
Modifier and Type | Field and Description |
---|---|
static int |
LOOP_FOREVER
A constant indicating that an animated drawable should loop continuously.
|
static int |
LOOP_INTRINSIC
A constant indicating that an animated drawable should loop for its default number of times.
|
Constructor and Description |
---|
GifDrawable(Context context,
GifDecoder gifDecoder,
BitmapPool bitmapPool,
Transformation<Bitmap> frameTransformation,
int targetFrameWidth,
int targetFrameHeight,
Bitmap firstFrame)
|
GifDrawable(Context context,
GifDecoder gifDecoder,
Transformation<Bitmap> frameTransformation,
int targetFrameWidth,
int targetFrameHeight,
Bitmap firstFrame)
Constructor for GifDrawable.
|
Modifier and Type | Method and Description |
---|---|
void |
draw(Canvas canvas) |
ByteBuffer |
getBuffer() |
Drawable.ConstantState |
getConstantState() |
Bitmap |
getFirstFrame() |
int |
getFrameCount() |
int |
getFrameIndex()
Returns the current frame index in the range 0..
getFrameCount() - 1, or -1 if no frame
is displayed. |
Transformation<Bitmap> |
getFrameTransformation() |
int |
getIntrinsicHeight() |
int |
getIntrinsicWidth() |
int |
getOpacity() |
int |
getSize() |
boolean |
isRunning() |
protected void |
onBoundsChange(Rect bounds) |
void |
onFrameReady() |
void |
recycle()
Clears any resources for loading frames that are currently held on to by this object.
|
void |
setAlpha(int i) |
void |
setColorFilter(ColorFilter colorFilter) |
void |
setFrameTransformation(Transformation<Bitmap> frameTransformation,
Bitmap firstFrame) |
void |
setLoopCount(int loopCount) |
boolean |
setVisible(boolean visible,
boolean restart) |
void |
start() |
void |
startFromFirstFrame()
Starts the animation from the first frame.
|
void |
stop() |
applyTheme, canApplyTheme, clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXml, createFromXmlInner, createFromXmlInner, getAlpha, getBounds, getCallback, getChangingConfigurations, getColorFilter, getCurrent, getDirtyBounds, getHotspotBounds, getLayoutDirection, getLevel, getMinimumHeight, getMinimumWidth, getOutline, getPadding, getState, getTransparentRegion, inflate, inflate, invalidateSelf, isAutoMirrored, isFilterBitmap, isStateful, isVisible, jumpToCurrentState, mutate, onLayoutDirectionChanged, onLevelChange, onStateChange, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setHotspot, setHotspotBounds, setLayoutDirection, setLevel, setState, setTint, setTintList, setTintMode, unscheduleSelf
public static final int LOOP_FOREVER
public static final int LOOP_INTRINSIC
@Deprecated public GifDrawable(Context context, GifDecoder gifDecoder, BitmapPool bitmapPool, Transformation<Bitmap> frameTransformation, int targetFrameWidth, int targetFrameHeight, Bitmap firstFrame)
context
- A context.bitmapPool
- Ignored, see deprecation note.frameTransformation
- An Transformation
that can be
applied to each frame.targetFrameWidth
- The desired width of the frames displayed by this drawable (the
width of the view or
Target
this drawable is being loaded into).targetFrameHeight
- The desired height of the frames displayed by this drawable (the
height of the view or
Target
this drawable is being loaded into).gifDecoder
- The decoder to use to decode GIF data.firstFrame
- The decoded and transformed first frame of this GIF.setFrameTransformation(com.bumptech.glide.load.Transformation, android.graphics.Bitmap)
public GifDrawable(Context context, GifDecoder gifDecoder, Transformation<Bitmap> frameTransformation, int targetFrameWidth, int targetFrameHeight, Bitmap firstFrame)
context
- A context.frameTransformation
- An Transformation
that can be
applied to each frame.targetFrameWidth
- The desired width of the frames displayed by this drawable (the
width of the view or
Target
this drawable is being loaded into).targetFrameHeight
- The desired height of the frames displayed by this drawable (the
height of the view or
Target
this drawable is being loaded into).gifDecoder
- The decoder to use to decode GIF data.firstFrame
- The decoded and transformed first frame of this GIF.setFrameTransformation(com.bumptech.glide.load.Transformation, android.graphics.Bitmap)
public int getSize()
public Bitmap getFirstFrame()
public void setFrameTransformation(Transformation<Bitmap> frameTransformation, Bitmap firstFrame)
public Transformation<Bitmap> getFrameTransformation()
public ByteBuffer getBuffer()
public int getFrameCount()
public int getFrameIndex()
getFrameCount()
- 1, or -1 if no frame
is displayed.public void startFromFirstFrame()
public void start()
start
in interface Animatable
public void stop()
stop
in interface Animatable
public boolean setVisible(boolean visible, boolean restart)
setVisible
in class Drawable
public int getIntrinsicWidth()
getIntrinsicWidth
in class Drawable
public int getIntrinsicHeight()
getIntrinsicHeight
in class Drawable
public boolean isRunning()
isRunning
in interface Animatable
protected void onBoundsChange(Rect bounds)
onBoundsChange
in class Drawable
public void setColorFilter(ColorFilter colorFilter)
setColorFilter
in class Drawable
public int getOpacity()
getOpacity
in class Drawable
public void onFrameReady()
onFrameReady
in interface com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback
public Drawable.ConstantState getConstantState()
getConstantState
in class Drawable
public void recycle()
public void setLoopCount(int loopCount)