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 Details

    • GifDrawableInit

      public GifDrawableInit()
  • Method Details

    • self

      protected abstract T self()
      Used in accordance with `getThis()` pattern.
      Returns:
      The builder type.
      See Also:
      link
    • sampleSize

      public T sampleSize​(@IntRange(from=1L,to=65535L) int sampleSize)
      Sample size controlling subsampling, see GifOptions.setInSampleSize(int) for more details. Note that this call will overwrite sample size set previously by options(GifOptions)
      Parameters:
      sampleSize - the sample size
      Returns:
      this builder instance, to chain calls
    • build

      public GifDrawable build() throws IOException
      Appropriate constructor wrapper. Must be preceded by on of from() calls.
      Returns:
      new drawable instance
      Throws:
      IOException - when creation fails
    • with

      public T with​(GifDrawable drawable)
      Sets drawable to be reused when creating new one.
      Parameters:
      drawable - drawable to be reused
      Returns:
      this builder instance, to chain calls
    • threadPoolSize

      public T threadPoolSize​(int threadPoolSize)
      Sets thread pool size for rendering tasks. Warning: custom executor set by taskExecutor(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

      public T taskExecutor​(ScheduledThreadPoolExecutor executor)
      Sets or resets executor for rendering tasks. Warning: value set by threadPoolSize(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

      public T renderingTriggeredOnDraw​(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). However animation will never run if drawable is set to not visible. See Drawable.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

      public T setRenderingTriggeredOnDraw​(boolean isRenderingTriggeredOnDraw)
      Equivalent to renderingTriggeredOnDraw(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

      @Beta public T options​(@Nullable GifOptions 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. See GifTextureView.setOpaque(boolean) for more information.
      Currently it is used only by GifTextureView, not by GifDrawable.

      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

      public T from​(InputStream inputStream)
      Parameters:
      inputStream - data source
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(AssetFileDescriptor assetFileDescriptor)
      Parameters:
      assetFileDescriptor - data source
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(FileDescriptor fileDescriptor)
      Parameters:
      fileDescriptor - data source
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(AssetManager assetManager, String assetName)
      Parameters:
      assetManager - assets source
      assetName - asset file name
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(ContentResolver contentResolver, Uri uri)
      Parameters:
      uri - data source
      contentResolver - resolver used to query uri
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(File file)
      Parameters:
      file - data source
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(String filePath)
      Parameters:
      filePath - data source
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(byte[] bytes)
      Parameters:
      bytes - data source
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(ByteBuffer byteBuffer)
      Parameters:
      byteBuffer - data source
      Returns:
      this builder instance, to chain calls
    • from

      public T from​(Resources resources, int resourceId)
      Parameters:
      resources - Resources to read from
      resourceId - resource id (data source)
      Returns:
      this builder instance, to chain calls
    • getInputSource

      public InputSource getInputSource()
      Getter for the input source.
      Returns:
      Current InputSource or null if it wasn't set.
    • getOldDrawable

      public GifDrawable getOldDrawable()
      Getter for the old drawable.
      Returns:
      Instance of the old GifDrawable or null if it wasn't set.
    • getExecutor

      public ScheduledThreadPoolExecutor getExecutor()
      Getter for the executor.
      Returns:
      ScheduledThreadPoolExecutor or 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

      public GifOptions getOptions()
      Getter for the GIF options.
      Returns:
      GifOptions.