Package com.castlabs.sdk.thumbs

# Class LoadingStrategy.Builder

java.lang.Object
com.castlabs.sdk.thumbs.LoadingStrategy.Builder

Enclosing class:
  LoadingStrategy

public static final class LoadingStrategy.Builder extends Object
Builder for `LoadingStrategy`. Waves can be added to the Strategy by chaining the addXWave methods. Note that order *is* important. Waves will be processed sequentially in adding order. The waves should be added in ascending order of density. For instance, adding a `TimeWave` of 1 minute followed by another of 10 seconds makes sense. But, if the order of those two waves was inverted, the first wave would load Thumbs every 10 seconds already and then the 1-minute wave would be useless.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `Builder()`
  Empty Builder
  `Builder(LoadingStrategy loadingStrategy)`
  Create a Builder with the provided LoadingStrategy.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `LoadingStrategy.Builder`
  `addPercentageWave(float percentage)`
  Adds a percentage Wave.
  `LoadingStrategy.Builder`
  `addStepWave(int step)`
  Adds a Step Wave.
  `LoadingStrategy.Builder`
  `addTimeWave(int time, TimeUnit timeUnit)`
  Adds a time Wave.
  `LoadingStrategy`
  `get()`
  Builds the `LoadingStrategy` with the Waves
  `LoadingStrategy.Builder`
  `loadStartDelayMs(long loadStartDelayMs)`
  Time in milliseconds after which the Thumbnails will start to be loaded.

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### Builder

    public Builder()
    Empty Builder

  - ### Builder

    public Builder(@Nullable LoadingStrategy loadingStrategy)
    Create a Builder with the provided LoadingStrategy. If null, an the starting strategy will be empty.
    Parameters:
      `loadingStrategy` - the strategy to initialise the Builder.

- ## Method Details

  - ### addTimeWave

    public LoadingStrategy.Builder addTimeWave(int time, @NonNull TimeUnit timeUnit)
    Adds a time Wave. Time waves define the amount of time between thumbnails.
    Parameters:
      `time` - Time to be the gap between any two consecutive loaded thumbnails
      `timeUnit` - TimeUnit. Must be greater or equal to 0.
    Returns:
      the builder

  - ### addPercentageWave

    public LoadingStrategy.Builder addPercentageWave(float percentage)
    Adds a percentage Wave. Defines the time percentage of the media between thumbnails.
    Parameters:
      `percentage` - percentage of the media to be the gap between any two consecutive loaded thumbnails. Must be between 0 and 1.
    Returns:
      the builder

  - ### addStepWave

    public LoadingStrategy.Builder addStepWave(int step)
    Adds a Step Wave. Defines the separation between the thumbnails, regardless of their duration.
    Parameters:
      `step` - the separation between two consecutive loaded thumbnails. Must be 1 or greater.
    Returns:
      the builder

  - ### loadStartDelayMs

    public LoadingStrategy.Builder loadStartDelayMs(long loadStartDelayMs)
    Time in milliseconds after which the Thumbnails will start to be loaded. Set to 0 to start loading immediately upon playback start. Set C.TIME_UNSET to start loading only on-demand, whenever `ThumbnailProvider.getThumbnail(long, ThumbnailProvider.Callback, int)` is called for the first time. Default is C.TIME_UNSET
    Parameters:
      `loadStartDelayMs` - delay time until thumbnail load start.
    Returns:
      the builder

  - ### get

    public LoadingStrategy get()
    Builds the `LoadingStrategy` with the Waves
    Returns:
      `LoadingStrategy` instance