public class

PAGView

extends TextureView
implements TextureView.SurfaceTextureListener LifecycleListener PAGAnimator.Listener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.TextureView
       ↳ org.libpag.PAGView

Summary

Nested Classes
interface PAGView.PAGFlushListener [Deprecated](Please use PAGViewListener's onAnimationUpdate instead.) PAG flush callback listener. 
interface PAGView.PAGViewListener  
[Expand]
Inherited Constants
From class android.view.View
[Expand]
Inherited Fields
From class android.view.View
Public Constructors
PAGView(Context context)
PAGView(Context context, EGLContext sharedContext)
PAGView(Context context, AttributeSet attrs)
PAGView(Context context, AttributeSet attrs, int defStyleAttr)
Public Methods
void addListener(PAGView.PAGViewListener 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.
void addPAGFlushListener(PAGView.PAGFlushListener listener)
[Deprecated](Please use PAGViewListener's onAnimationUpdate instead.) Adds a PAGFlushListener to the set of listeners that are sent events when pag flush called.
boolean cacheEnabled()
If set to true, PAG renderer caches an internal bitmap representation of the static content for each layer.
float cacheScale()
This value defines the scale factor for internal graphics caches, ranges from 0.0 to 1.0.
long currentFrame()
Returns the current frame.
long duration()
The duration of current composition in microseconds.
boolean flush()
Call this method to render current position immediately.
void freeCache()
Free the cache created by the pag view immediately.
RectF getBounds(PAGLayer pagLayer)
Returns a rectangle in pixels that defines the displaying area of the specified layer, which is in the coordinate of the PAGView.
PAGComposition getComposition()
Returns the current PAGComposition for PAGView to render as content.
PAGLayer[] getLayersUnderPoint(float x, float y)
Returns an array of layers that lie under the specified point.
String getPath()
The path string of a pag file set by setPath().
double getProgress()
Returns the current progress of play position, the value is from 0.0 to 1.0.
boolean isPlaying()
Indicates whether the animation is playing.
boolean isSync()
Returns true if PAGView is playing in the main thread.
Bitmap makeSnapshot()
Returns a bitmap capturing the contents of the PAGView.
Matrix matrix()
Returns a copy of current matrix.
float maxFrameRate()
The maximum frame rate for rendering.
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 onResume()
void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height)
boolean onSurfaceTextureDestroyed(SurfaceTexture surface)
void onSurfaceTextureSizeChanged(SurfaceTexture surfaceTexture, int width, int height)
void onSurfaceTextureUpdated(SurfaceTexture surface)
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(PAGView.PAGViewListener listener)
Removes a listener from the set listening to this animation.
void removePAGFlushListener(PAGView.PAGFlushListener listener)
[Deprecated](Please use PAGViewListener's onAnimationUpdate instead.) Removes a PAGFlushListener to the set of listeners that are sent events when pag flush called.
int repeatCount()
The total number of times the animation is set to play.
int scaleMode()
Returns the current scale mode.
void setBackgroundDrawable(Drawable background)
void setCacheEnabled(boolean value)
Sets the value of cacheEnabled property.
void setCacheScale(float value)
Sets the value of cacheScale property.
void setComposition(PAGComposition newComposition)
Sets a new PAGComposition for PAGView to render as content.
void setMatrix(Matrix matrix)
Sets the transformation which will be applied to the composition.
void setMaxFrameRate(float value)
Sets the maximum frame rate for rendering.
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.
void setPathAsync(String path, PAGFile.LoadListener listener)
Asynchronously load a pag file from the specific path.
void setProgress(double value)
Sets the progress of play position, the valid value is from 0.0 to 1.0.
void setRepeatCount(int repeatCount)
Set the number of times the animation to play.
void setScaleMode(int mode)
Specifies the rule of how to scale the pag content to fit the surface size.
void setSurfaceTextureListener(TextureView.SurfaceTextureListener listener)
void setSync(boolean isSync)
Sets the sync flag for the PAGView.
void setUseDiskCache(boolean value)
Set the value of useDiskCache property.
void setVideoEnabled(boolean enable)
Sets the value of videoEnabled property.
void stop()
Cancels the animation at the current position.
boolean useDiskCache()
If set to true, PAG will cache the associated rendering data into a disk file, such as the decoded image frames of video compositions.
boolean videoEnabled()
If set to false, PAGView skips rendering for video composition.
Protected Methods
void onAttachedToWindow()
void onDetachedFromWindow()
[Expand]
Inherited Methods
From class android.view.TextureView
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.TextureView.SurfaceTextureListener
From interface android.view.accessibility.AccessibilityEventSource
From interface org.extra.tools.LifecycleListener
From interface org.libpag.PAGAnimator.Listener

Public Constructors

public PAGView (Context context)

public PAGView (Context context, EGLContext sharedContext)

public PAGView (Context context, AttributeSet attrs)

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

Public Methods

public void addListener (PAGView.PAGViewListener 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 void addPAGFlushListener (PAGView.PAGFlushListener listener)

[Deprecated](Please use PAGViewListener's onAnimationUpdate instead.) Adds a PAGFlushListener to the set of listeners that are sent events when pag flush called. the listener onFlush is called on main thread.

public boolean cacheEnabled ()

If set to true, PAG renderer caches an internal bitmap representation of the static content for each layer. This caching can increase performance for layers that contain complex vector content. The execution speed can be significantly faster depending on the complexity of the content, but it requires extra graphics memory. The default value is true.

public float cacheScale ()

This value defines the scale factor for internal graphics caches, ranges from 0.0 to 1.0. The scale factors less than 1.0 may result in blurred output, but it can reduce the usage of graphics memory which leads to better performance. The default value is 1.0.

public long currentFrame ()

Returns the current frame.

public long duration ()

The duration of current composition in microseconds.

public boolean flush ()

Call this method to render current position immediately. Note that all the changes previously made to the PAGView 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 void freeCache ()

Free the cache created by the pag view immediately. Can be called to reduce memory pressure.

public RectF getBounds (PAGLayer pagLayer)

Returns a rectangle in pixels that defines the displaying area of the specified layer, which is in the coordinate of the PAGView.

public PAGComposition getComposition ()

Returns the current PAGComposition for PAGView to render as content.

public PAGLayer[] getLayersUnderPoint (float x, float y)

Returns an array of layers that lie under the specified point. The point is in pixels not dp.

public String getPath ()

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

public double getProgress ()

Returns the current progress of play position, the value is from 0.0 to 1.0.

public boolean isPlaying ()

Indicates whether the animation is playing.

public boolean isSync ()

Returns true if PAGView is playing in the main thread. The default value is false.

public Bitmap makeSnapshot ()

Returns a bitmap capturing the contents of the PAGView. Subsequent rendering of the PAGView will not be captured. Returns null if the PAGView hasn't been presented yet.

public Matrix matrix ()

Returns a copy of current matrix.

public float maxFrameRate ()

The maximum frame rate for rendering. If set to a value less than the actual frame rate from PAGFile, it drops frames but increases performance. Otherwise, it has no effect. The default value is 60.

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 onResume ()

public void onSurfaceTextureAvailable (SurfaceTexture surface, int width, int height)

public boolean onSurfaceTextureDestroyed (SurfaceTexture surface)

public void onSurfaceTextureSizeChanged (SurfaceTexture surfaceTexture, int width, int height)

public void onSurfaceTextureUpdated (SurfaceTexture surface)

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 (PAGView.PAGViewListener listener)

Removes a listener from the set listening to this animation.

public void removePAGFlushListener (PAGView.PAGFlushListener listener)

[Deprecated](Please use PAGViewListener's onAnimationUpdate instead.) Removes a PAGFlushListener to the set of listeners that are sent events when pag flush called. The listener onFlush is called on main thread.

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 setBackgroundDrawable (Drawable background)

public void setCacheEnabled (boolean value)

Sets the value of cacheEnabled property.

public void setCacheScale (float value)

Sets the value of cacheScale property.

public void setComposition (PAGComposition newComposition)

Sets a new PAGComposition for PAGView to render as content. Note that if the composition is already added to another PAGView, it will be removed from the previous PAGView.

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 void setMaxFrameRate (float value)

Sets the maximum frame rate for rendering.

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. Note: All PAGFiles loaded by the same path share the same internal cache. The internal cache remains alive until all PAGFiles are released. Use 'PAGFile.Load(byte[])' instead if you don't want to load a PAGFile from the internal caches.

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

Asynchronously load a pag file from the specific path.

public void setProgress (double value)

Sets the progress of play position, the valid value is from 0.0 to 1.0.

public void setRepeatCount (int repeatCount)

Set the number of times the animation to play.

public void setScaleMode (int mode)

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

public void setSurfaceTextureListener (TextureView.SurfaceTextureListener listener)

public void setSync (boolean isSync)

Sets the sync flag for the PAGView.

public void setUseDiskCache (boolean value)

Set the value of useDiskCache property.

public void setVideoEnabled (boolean enable)

Sets the value of videoEnabled property.

public void stop ()

Cancels the animation at the current position. Currently, it has the same effect as pause().

public boolean useDiskCache ()

If set to true, PAG will cache the associated rendering data into a disk file, such as the decoded image frames of video compositions. This can help reduce memory usage and improve rendering performance.

public boolean videoEnabled ()

If set to false, PAGView skips rendering for video composition.

Protected Methods

protected void onAttachedToWindow ()

protected void onDetachedFromWindow ()