Package pl.droidsonroids.gif
Class GifDrawableInit<T extends GifDrawableInit<T>>
java.lang.Object
pl.droidsonroids.gif.GifDrawableInit<T>
- Type Parameters:
T- The type of the builder that is a subclass of this class.
- Direct Known Subclasses:
GifDrawableBuilder
public abstract class GifDrawableInit<T extends GifDrawableInit<T>> extends Object
The base class for using the builder pattern with subclasses.
- See Also:
- link
-
Constructor Summary
Constructors Constructor Description GifDrawableInit() -
Method Summary
Modifier and Type Method Description GifDrawablebuild()Appropriate constructor wrapper.Tfrom(byte[] bytes)Wrapper ofGifDrawable(byte[])Tfrom(ContentResolver contentResolver, Uri uri)Tfrom(AssetFileDescriptor assetFileDescriptor)Tfrom(AssetManager assetManager, String assetName)Tfrom(Resources resources, int resourceId)Tfrom(File file)Wrapper ofGifDrawable(java.io.File)Tfrom(FileDescriptor fileDescriptor)Wrapper ofGifDrawable(java.io.FileDescriptor)Tfrom(InputStream inputStream)Wrapper ofGifDrawable(java.io.InputStream)Tfrom(String filePath)Wrapper ofGifDrawable(java.lang.String)Tfrom(ByteBuffer byteBuffer)Wrapper ofGifDrawable(java.nio.ByteBuffer)ScheduledThreadPoolExecutorgetExecutor()Getter for the executor.InputSourcegetInputSource()Getter for the input source.GifDrawablegetOldDrawable()Getter for the old drawable.GifOptionsgetOptions()Getter for the GIF options.booleanisRenderingTriggeredOnDraw()Toptions(GifOptions options)Indicates whether the content of this source is opaque.TrenderingTriggeredOnDraw(boolean isRenderingTriggeredOnDraw)Sets whether rendering of the next frame is scheduled after drawing current one (so animation will be paused if drawing does not happen) or just after rendering frame (no matter if it is drawn or not).TsampleSize(int sampleSize)Sample size controlling subsampling, seeGifOptions.setInSampleSize(int)for more details.protected abstract Tself()Used in accordance with `getThis()` pattern.TsetRenderingTriggeredOnDraw(boolean isRenderingTriggeredOnDraw)Equivalent torenderingTriggeredOnDraw(boolean).TtaskExecutor(ScheduledThreadPoolExecutor executor)Sets or resets executor for rendering tasks.TthreadPoolSize(int threadPoolSize)Sets thread pool size for rendering tasks.Twith(GifDrawable drawable)Sets drawable to be reused when creating new one.
-
Constructor Details
-
GifDrawableInit
public GifDrawableInit()
-
-
Method Details
-
self
Used in accordance with `getThis()` pattern.- Returns:
- The builder type.
- See Also:
- link
-
sampleSize
Sample size controlling subsampling, seeGifOptions.setInSampleSize(int)for more details. Note that this call will overwrite sample size set previously byoptions(GifOptions)- Parameters:
sampleSize- the sample size- Returns:
- this builder instance, to chain calls
-
build
Appropriate constructor wrapper. Must be preceded by on offrom()calls.- Returns:
- new drawable instance
- Throws:
IOException- when creation fails
-
with
Sets drawable to be reused when creating new one.- Parameters:
drawable- drawable to be reused- Returns:
- this builder instance, to chain calls
-
threadPoolSize
Sets thread pool size for rendering tasks. Warning: custom executor set bytaskExecutor(java.util.concurrent.ScheduledThreadPoolExecutor)will be overwritten after setting pool size- Parameters:
threadPoolSize- size of the pool- Returns:
- this builder instance, to chain calls
-
taskExecutor
Sets or resets executor for rendering tasks. Warning: value set bythreadPoolSize(int)will not be taken into account after setting executor- Parameters:
executor- executor to be used or null for default (each drawable instance has its own executor)- Returns:
- this builder instance, to chain calls
-
renderingTriggeredOnDraw
Sets whether rendering of the next frame is scheduled after drawing current one (so animation will be paused if drawing does not happen) or just after rendering frame (no matter if it is drawn or not). However animation will never run if drawable is set to not visible. SeeDrawable.isVisible()for more information about drawable visibility. By default this option is enabled. Note that drawing does not happen if view containing drawable is obscured. Disabling this option will prevent that however battery draining will be higher.- Parameters:
isRenderingTriggeredOnDraw- whether rendering of the next frame is scheduled after drawing (default) current one or just after it is rendered- Returns:
- this builder instance, to chain calls
-
setRenderingTriggeredOnDraw
Equivalent torenderingTriggeredOnDraw(boolean). This method does not follow naming convention and is preserved for backwards compatibility only.- Parameters:
isRenderingTriggeredOnDraw- whether rendering of the next frame is scheduled after drawing (default) current one or just after it is rendered- Returns:
- this builder instance, to chain calls
-
options
Indicates whether the content of this source is opaque. GIF that is known to be opaque can take a faster drawing case than non-opaque one. SeeGifTextureView.setOpaque(boolean)for more information.
Currently it is used only byGifTextureView, not byGifDrawable.Note that this call will overwrite sample size set previously by
sampleSize(int)- Parameters:
options- null-ok; options controlling parameters like subsampling and opacity- Returns:
- this builder instance, to chain calls
-
from
Wrapper ofGifDrawable(java.io.InputStream)- Parameters:
inputStream- data source- Returns:
- this builder instance, to chain calls
-
from
- Parameters:
assetFileDescriptor- data source- Returns:
- this builder instance, to chain calls
-
from
Wrapper ofGifDrawable(java.io.FileDescriptor)- Parameters:
fileDescriptor- data source- Returns:
- this builder instance, to chain calls
-
from
- Parameters:
assetManager- assets sourceassetName- asset file name- Returns:
- this builder instance, to chain calls
-
from
- Parameters:
uri- data sourcecontentResolver- resolver used to queryuri- Returns:
- this builder instance, to chain calls
-
from
Wrapper ofGifDrawable(java.io.File)- Parameters:
file- data source- Returns:
- this builder instance, to chain calls
-
from
Wrapper ofGifDrawable(java.lang.String)- Parameters:
filePath- data source- Returns:
- this builder instance, to chain calls
-
from
Wrapper ofGifDrawable(byte[])- Parameters:
bytes- data source- Returns:
- this builder instance, to chain calls
-
from
Wrapper ofGifDrawable(java.nio.ByteBuffer)- Parameters:
byteBuffer- data source- Returns:
- this builder instance, to chain calls
-
from
- Parameters:
resources- Resources to read fromresourceId- resource id (data source)- Returns:
- this builder instance, to chain calls
-
getInputSource
Getter for the input source.- Returns:
- Current
InputSourceor null if it wasn't set.
-
getOldDrawable
Getter for the old drawable.- Returns:
- Instance of the old
GifDrawableor null if it wasn't set.
-
getExecutor
Getter for the executor.- Returns:
ScheduledThreadPoolExecutoror null if it wasn't set.
-
isRenderingTriggeredOnDraw
public boolean isRenderingTriggeredOnDraw()- Returns:
- True if rendering of the next frame is scheduled after drawing, false otherwise.
-
getOptions
Getter for the GIF options.- Returns:
GifOptions.
-