com.bumptech.glide.load.resource.gif
Class GifDrawable

java.lang.Object
  extended by android.graphics.drawable.Drawable
      extended by com.bumptech.glide.load.resource.drawable.GlideDrawable
          extended by com.bumptech.glide.load.resource.gif.GifDrawable
All Implemented Interfaces:
android.graphics.drawable.Animatable, com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback

public class GifDrawable
extends GlideDrawable
implements com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback

An animated Drawable that plays the frames of an animated GIF.


Nested Class Summary
 
Nested classes/interfaces inherited from class android.graphics.drawable.Drawable
android.graphics.drawable.Drawable.Callback, android.graphics.drawable.Drawable.ConstantState
 
Field Summary
 
Fields inherited from class com.bumptech.glide.load.resource.drawable.GlideDrawable
LOOP_FOREVER, LOOP_INTRINSIC
 
Constructor Summary
GifDrawable(android.content.Context context, GifDecoder.BitmapProvider bitmapProvider, BitmapPool bitmapPool, Transformation<android.graphics.Bitmap> frameTransformation, int targetFrameWidth, int targetFrameHeight, GifHeader gifHeader, byte[] data, android.graphics.Bitmap firstFrame)
          Constructor for GifDrawable.
GifDrawable(GifDrawable other, android.graphics.Bitmap firstFrame, Transformation<android.graphics.Bitmap> frameTransformation)
           
 
Method Summary
 void draw(android.graphics.Canvas canvas)
           
 android.graphics.drawable.Drawable.ConstantState getConstantState()
           
 byte[] getData()
           
 GifDecoder getDecoder()
           
 android.graphics.Bitmap getFirstFrame()
           
 int getFrameCount()
           
 Transformation<android.graphics.Bitmap> getFrameTransformation()
           
 int getIntrinsicHeight()
           
 int getIntrinsicWidth()
           
 int getOpacity()
           
 boolean isAnimated()
          Returns true if this drawable is animated.
 boolean isRunning()
           
protected  void onBoundsChange(android.graphics.Rect bounds)
           
 void onFrameReady(int frameIndex)
           
 void recycle()
          Clears any resources for loading frames that are currently held on to by this object.
 void setAlpha(int i)
           
 void setColorFilter(android.graphics.ColorFilter colorFilter)
           
 void setFrameTransformation(Transformation<android.graphics.Bitmap> frameTransformation, android.graphics.Bitmap firstFrame)
           
 void setLoopCount(int loopCount)
          Sets the number of times the animation should loop.
 boolean setVisible(boolean visible, boolean restart)
           
 void start()
           
 void stop()
           
 
Methods inherited from class android.graphics.drawable.Drawable
clearColorFilter, copyBounds, copyBounds, createFromPath, createFromResourceStream, createFromResourceStream, createFromStream, createFromXml, createFromXmlInner, getAlpha, getBounds, getCallback, getChangingConfigurations, getCurrent, getLevel, getMinimumHeight, getMinimumWidth, getPadding, getState, getTransparentRegion, inflate, invalidateSelf, isAutoMirrored, isStateful, isVisible, jumpToCurrentState, mutate, onLevelChange, onStateChange, resolveOpacity, scheduleSelf, setAutoMirrored, setBounds, setBounds, setCallback, setChangingConfigurations, setColorFilter, setDither, setFilterBitmap, setLevel, setState, unscheduleSelf
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GifDrawable

public GifDrawable(android.content.Context context,
                   GifDecoder.BitmapProvider bitmapProvider,
                   BitmapPool bitmapPool,
                   Transformation<android.graphics.Bitmap> frameTransformation,
                   int targetFrameWidth,
                   int targetFrameHeight,
                   GifHeader gifHeader,
                   byte[] data,
                   android.graphics.Bitmap firstFrame)
Constructor for GifDrawable.

Parameters:
context - A context.
bitmapProvider - An GifDecoder.BitmapProvider that can be used to retrieve re-usable Bitmaps.
bitmapPool - A BitmapPool that can be used to return the first frame when this drawable is recycled.
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).
gifHeader - The header data for this gif.
data - The full bytes of the gif.
firstFrame - The decoded and transformed first frame of this gif.
See Also:
setFrameTransformation(com.bumptech.glide.load.Transformation, android.graphics.Bitmap)

GifDrawable

public GifDrawable(GifDrawable other,
                   android.graphics.Bitmap firstFrame,
                   Transformation<android.graphics.Bitmap> frameTransformation)
Method Detail

getFirstFrame

public android.graphics.Bitmap getFirstFrame()

setFrameTransformation

public void setFrameTransformation(Transformation<android.graphics.Bitmap> frameTransformation,
                                   android.graphics.Bitmap firstFrame)

getDecoder

public GifDecoder getDecoder()

getFrameTransformation

public Transformation<android.graphics.Bitmap> getFrameTransformation()

getData

public byte[] getData()

getFrameCount

public int getFrameCount()

start

public void start()
Specified by:
start in interface android.graphics.drawable.Animatable

stop

public void stop()
Specified by:
stop in interface android.graphics.drawable.Animatable

setVisible

public boolean setVisible(boolean visible,
                          boolean restart)
Overrides:
setVisible in class android.graphics.drawable.Drawable

getIntrinsicWidth

public int getIntrinsicWidth()
Overrides:
getIntrinsicWidth in class android.graphics.drawable.Drawable

getIntrinsicHeight

public int getIntrinsicHeight()
Overrides:
getIntrinsicHeight in class android.graphics.drawable.Drawable

isRunning

public boolean isRunning()
Specified by:
isRunning in interface android.graphics.drawable.Animatable

onBoundsChange

protected void onBoundsChange(android.graphics.Rect bounds)
Overrides:
onBoundsChange in class android.graphics.drawable.Drawable

draw

public void draw(android.graphics.Canvas canvas)
Specified by:
draw in class android.graphics.drawable.Drawable

setAlpha

public void setAlpha(int i)
Specified by:
setAlpha in class android.graphics.drawable.Drawable

setColorFilter

public void setColorFilter(android.graphics.ColorFilter colorFilter)
Specified by:
setColorFilter in class android.graphics.drawable.Drawable

getOpacity

public int getOpacity()
Specified by:
getOpacity in class android.graphics.drawable.Drawable

onFrameReady

public void onFrameReady(int frameIndex)
Specified by:
onFrameReady in interface com.bumptech.glide.load.resource.gif.GifFrameLoader.FrameCallback

getConstantState

public android.graphics.drawable.Drawable.ConstantState getConstantState()
Overrides:
getConstantState in class android.graphics.drawable.Drawable

recycle

public void recycle()
Clears any resources for loading frames that are currently held on to by this object.


isAnimated

public boolean isAnimated()
Description copied from class: GlideDrawable
Returns true if this drawable is animated.

Specified by:
isAnimated in class GlideDrawable

setLoopCount

public void setLoopCount(int loopCount)
Description copied from class: GlideDrawable
Sets the number of times the animation should loop. This method will only have an affect if ()} returns true. A loop count of <=0 indicates loop forever.

Specified by:
setLoopCount in class GlideDrawable