public class GifDrawable extends Drawable implements com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback, Animatable, Animatable2Compat
Drawable
that plays the frames of an animated GIF.Drawable.Callback, Drawable.ConstantState
Animatable2Compat.AnimationCallback
限定符和类型 | 字段和说明 |
---|---|
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.
|
构造器和说明 |
---|
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.
|
限定符和类型 | 方法和说明 |
---|---|
void |
clearAnimationCallbacks() |
void |
draw(Canvas canvas) |
ByteBuffer |
getBuffer() |
Drawable.ConstantState |
getConstantState() |
Bitmap |
getFirstFrame() |
int |
getFrameCount() |
int |
getFrameIndex()
Returns the current frame index in the range 0..
|
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 |
registerAnimationCallback(Animatable2Compat.AnimationCallback animationCallback)
Register callback to listen to GifDrawable animation end event after specific loop count
set by
setLoopCount(int) . |
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() |
boolean |
unregisterAnimationCallback(Animatable2Compat.AnimationCallback animationCallback) |
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
在接口中 Animatable
public void stop()
stop
在接口中 Animatable
public boolean setVisible(boolean visible, boolean restart)
setVisible
在类中 Drawable
public int getIntrinsicWidth()
getIntrinsicWidth
在类中 Drawable
public int getIntrinsicHeight()
getIntrinsicHeight
在类中 Drawable
public boolean isRunning()
isRunning
在接口中 Animatable
protected void onBoundsChange(Rect bounds)
onBoundsChange
在类中 Drawable
public void setColorFilter(ColorFilter colorFilter)
setColorFilter
在类中 Drawable
public int getOpacity()
getOpacity
在类中 Drawable
public void onFrameReady()
onFrameReady
在接口中 com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback
public Drawable.ConstantState getConstantState()
getConstantState
在类中 Drawable
public void recycle()
public void setLoopCount(int loopCount)
public void registerAnimationCallback(@NonNull Animatable2Compat.AnimationCallback animationCallback)
setLoopCount(int)
.
Note: This will only be called if the Gif stop because it reaches the loop count. Unregister
this in onLoadCleared to avoid potential memory leak.registerAnimationCallback
在接口中 Animatable2Compat
animationCallback
- Animation callback Animatable2Compat.AnimationCallback
.Animatable2Compat.unregisterAnimationCallback(AnimationCallback).
public boolean unregisterAnimationCallback(@NonNull Animatable2Compat.AnimationCallback animationCallback)
unregisterAnimationCallback
在接口中 Animatable2Compat
public void clearAnimationCallbacks()
clearAnimationCallbacks
在接口中 Animatable2Compat