public class

GifImageView

extends ImageView
java.lang.Object
   ↳ ImageView
     ↳ co.megacool.megacool.GifImageView

Class Overview

A view that can display a GIF. You usually won't create this yourself. The GIF is initially paused, call start() to start playing. This class is safe to modify from any thread. When the GIF preview is no longer needed, it must be destroyed by calling destroy(). Attempting to start a GIF that was previously destroyed will result in undefined behavior

Summary

Public Constructors
GifImageView(Context context)
GifImageView(Context context, AttributeSet attrs)
GifImageView(Context context, AttributeSet attrs, int defStyleAttr)
Public Methods
void destroy()
Call this when you are finished with the GIF preview.
int getNumberOfFrames()
boolean isRunning()
void onWindowFocusChanged(boolean hasWindowFocus)
Used to detect when the preview is visible to automatically pause/start it
void setRepeat(boolean repeat)
By default the GIF will loop endlessly.
void start()
Start animating the GIF.
void stop()
Stop animating the GIF.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public GifImageView (Context context)

public GifImageView (Context context, AttributeSet attrs)

public GifImageView (Context context, AttributeSet attrs, int defStyleAttr)

Public Methods

public void destroy ()

Call this when you are finished with the GIF preview. Failure to call this may result in memory leaks. Once you have called this, the GifImageView will still be present on the screen, but it will no longer run. Should you wish to continue playing the GIF again, you will need to create a new GifImageView

public int getNumberOfFrames ()

Returns
  • the number of frames in the GIF

public boolean isRunning ()

Returns
  • whether the GIF is currently animating

public void onWindowFocusChanged (boolean hasWindowFocus)

Used to detect when the preview is visible to automatically pause/start it

Parameters
hasWindowFocus true if visible, false if not

public void setRepeat (boolean repeat)

By default the GIF will loop endlessly. Set this to false to only play the GIF once.

Parameters
repeat whether the GIF should repeat after the first play

public void start ()

Start animating the GIF.

public void stop ()

Stop animating the GIF.