public class

PAGImageView

extends View
implements PAGAnimator.Listener
java.lang.Object
   ↳ android.view.View
     ↳ org.libpag.PAGImageView

Summary

Nested Classes
interface PAGImageView.PAGImageViewListener  
[Expand]
Inherited Constants
From class android.view.View
Fields
protected PAGImageViewHelper.DecoderInfo decoderInfo
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PAGImageView(Context context)
PAGImageView(Context context, AttributeSet attrs)
PAGImageView(Context context, AttributeSet attrs, int defStyleAttr)
Public Methods
static long MaxDiskCache()
[Deprecated](Please use PAGDiskCache.MaxDiskSize() instead.) Returns the size limit of the disk cache in bytes.
static void SetMaxDiskCache(long maxDiskCache)
[Deprecated](Please use PAGDiskCache.SetMaxDiskSize() instead.) Sets the size limit of the disk cache in bytes.
void addListener(PAGImageView.PAGImageViewListener listener)
Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.
boolean cacheAllFramesInMemory()
If set to true, the PAGImageView loads all image frames into the memory, which will significantly increase the rendering performance but may cost lots of additional memory.
int currentFrame()
Returns the current frame index the PAGImageView is rendering.
Bitmap currentImage()
Returns a bitmap capturing the contents of the current PAGImageView.
boolean flush()
Renders the current image frame immediately.
PAGComposition getComposition()
Returns the current PAGComposition in the PAGImageView.
String getPath()
The path string of a pag file set by setPath().
boolean isPlaying()
Indicates whether the animation is playing.
Matrix matrix()
Returns a copy of the current matrix.
int numFrames()
Returns the number of frames in the PAGImageView in one loop.
void onAnimationCancel(PAGAnimator animator)
Notifies the cancellation of the animation.
void onAnimationEnd(PAGAnimator animator)
Notifies the end of the animation.
void onAnimationRepeat(PAGAnimator animator)
Notifies the repetition of the animation.
void onAnimationStart(PAGAnimator animator)
Notifies the start of the animation.
void onAnimationUpdate(PAGAnimator animator)
Notifies another frame of the animation has occurred.
void onVisibilityAggregated(boolean isVisible)
void pause()
Cancels the animation at the current position.
void play()
Starts to play the animation from the current position.
void removeListener(PAGImageView.PAGImageViewListener listener)
Removes a listener from the set listening to this animation.
float renderScale()
This value defines the scale factor for the size of the cached image frames, which ranges from 0.0 to 1.0.
int repeatCount()
The total number of times the animation is set to play.
int scaleMode()
Returns the current scale mode.
void setCacheAllFramesInMemory(boolean enable)
Sets the value of the cacheAllFramesInMemory property.
void setComposition(PAGComposition newComposition)
Sets a new PAGComposition to the PAGImageView with the maxFrameRate set to 30 fps.
void setComposition(PAGComposition newComposition, float maxFrameRate)
Sets a new PAGComposition and the maxFrameRate limit to the PAGImageView.
void setCurrentFrame(int currentFrame)
Sets the frame index for the PAGImageView to render.
void setMatrix(Matrix matrix)
Sets the transformation which will be applied to the composition.
boolean setPath(String path)
Loads a pag file from the specified path, returns false if the file does not exist or the data is not a pag file.
boolean setPath(String path, float maxFrameRate)
Loads a pag file from the specified path with the maxFrameRate limit, returns false if the file does not exist or the data is not a pag file.
void setPathAsync(String path, float maxFrameRate, PAGFile.LoadListener listener)
Asynchronously loads a pag file from the specified path with the maxFrameRate limit.
void setPathAsync(String path, PAGFile.LoadListener listener)
Asynchronously Loads a pag file from the specified path.
void setRenderScale(float renderScale)
Sets the value of the renderScale property.
void setRepeatCount(int value)
Set the number of times the animation to play.
void setScaleMode(int scaleMode)
Specifies the rule of how to scale the pag content to fit the PAGImageView's size.
Protected Methods
void finalize()
void initDecoderInfo()
void onAttachedToWindow()
void onDetachedFromWindow()
void onDraw(Canvas canvas)
void onSizeChanged(int w, int h, int oldw, int oldh)
[Expand]
Inherited Methods
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource
From interface org.libpag.PAGAnimator.Listener

Fields

protected PAGImageViewHelper.DecoderInfo decoderInfo

Public Constructors

public PAGImageView (Context context)

public PAGImageView (Context context, AttributeSet attrs)

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

Public Methods

public static long MaxDiskCache ()

[Deprecated](Please use PAGDiskCache.MaxDiskSize() instead.) Returns the size limit of the disk cache in bytes.

public static void SetMaxDiskCache (long maxDiskCache)

[Deprecated](Please use PAGDiskCache.SetMaxDiskSize() instead.) Sets the size limit of the disk cache in bytes. The default disk cache limit is 1 GB.

public void addListener (PAGImageView.PAGImageViewListener listener)

Adds a listener to the set of listeners that are sent events through the life of an animation, such as start, repeat, and end.

public boolean cacheAllFramesInMemory ()

If set to true, the PAGImageView loads all image frames into the memory, which will significantly increase the rendering performance but may cost lots of additional memory. Set it to true if you prefer rendering speed over memory usage. If set to false, the PAGImageView loads only one image frame at a time into the memory. The default value is false.

public int currentFrame ()

Returns the current frame index the PAGImageView is rendering.

public Bitmap currentImage ()

Returns a bitmap capturing the contents of the current PAGImageView.

public boolean flush ()

Renders the current image frame immediately. Note that all the changes previously made to the PAGImageView will only take effect after this method is called. If the play() method is already called, there is no need to call it manually since it will be automatically called every frame. Returns true if the content has changed.

public PAGComposition getComposition ()

Returns the current PAGComposition in the PAGImageView. Returns null if the internal composition was loaded from a pag file path.

public String getPath ()

The path string of a pag file set by setPath().

public boolean isPlaying ()

Indicates whether the animation is playing.

public Matrix matrix ()

Returns a copy of the current matrix.

public int numFrames ()

Returns the number of frames in the PAGImageView in one loop. Note that the value may change if the associated PAGComposition was modified.

public void onAnimationCancel (PAGAnimator animator)

Notifies the cancellation of the animation. It can be called from either the UI thread or the thread that calls the cancel() method.

public void onAnimationEnd (PAGAnimator animator)

Notifies the end of the animation. It can only be called from the UI thread.

public void onAnimationRepeat (PAGAnimator animator)

Notifies the repetition of the animation. It can only be called from the UI thread.

public void onAnimationStart (PAGAnimator animator)

Notifies the start of the animation. It can be called from either the UI thread or the thread that calls the start() method.

public void onAnimationUpdate (PAGAnimator animator)

Notifies another frame of the animation has occurred. It may be called from an arbitrary thread if the animation is running asynchronously.

public void onVisibilityAggregated (boolean isVisible)

public void pause ()

Cancels the animation at the current position. Calling the play() method can resume the animation from the last paused position.

public void play ()

Starts to play the animation from the current position. Calling the play() method when the animation is already playing has no effect. The play() method does not alter the animation's current position. However, if the animation previously reached its end, it will restart from the beginning.

public void removeListener (PAGImageView.PAGImageViewListener listener)

Removes a listener from the set listening to this animation.

public float renderScale ()

This value defines the scale factor for the size of the cached image frames, which ranges from 0.0 to 1.0. A scale factor less than 1.0 may result in blurred output, but it can reduce graphics memory usage, increasing the rendering performance. The default value is 1.0.

public int repeatCount ()

The total number of times the animation is set to play. The default is 1, which means the animation will play only once. If the repeat count is set to 0 or a negative value, the animation will play infinity times.

public int scaleMode ()

Returns the current scale mode.

public void setCacheAllFramesInMemory (boolean enable)

Sets the value of the cacheAllFramesInMemory property.

public void setComposition (PAGComposition newComposition)

Sets a new PAGComposition to the PAGImageView with the maxFrameRate set to 30 fps. Note: If the composition is already added to another PAGImageView, it will be removed from the previous PAGImageView.

public void setComposition (PAGComposition newComposition, float maxFrameRate)

Sets a new PAGComposition and the maxFrameRate limit to the PAGImageView. Note: If the composition is already added to another PAGImageView, it will be removed from the previous PAGImageView.

public void setCurrentFrame (int currentFrame)

Sets the frame index for the PAGImageView to render.

public void setMatrix (Matrix matrix)

Sets the transformation which will be applied to the composition. The scaleMode property will be set to PAGScaleMode::None when this method is called.

public boolean setPath (String path)

Loads a pag file from the specified path, returns false if the file does not exist or the data is not a pag file. The path starts with "assets://" means that it is located in assets directory.

public boolean setPath (String path, float maxFrameRate)

Loads a pag file from the specified path with the maxFrameRate limit, returns false if the file does not exist or the data is not a pag file. The path starts with "assets://" means that it is located in assets directory.

public void setPathAsync (String path, float maxFrameRate, PAGFile.LoadListener listener)

Asynchronously loads a pag file from the specified path with the maxFrameRate limit.

public void setPathAsync (String path, PAGFile.LoadListener listener)

Asynchronously Loads a pag file from the specified path.

public void setRenderScale (float renderScale)

Sets the value of the renderScale property.

public void setRepeatCount (int value)

Set the number of times the animation to play.

public void setScaleMode (int scaleMode)

Specifies the rule of how to scale the pag content to fit the PAGImageView's size. The current matrix of the PAGImageView changes when this method is called.

Protected Methods

protected void finalize ()

Throws
Throwable

protected void initDecoderInfo ()

protected void onAttachedToWindow ()

protected void onDetachedFromWindow ()

protected void onDraw (Canvas canvas)

protected void onSizeChanged (int w, int h, int oldw, int oldh)