Class PreloadTarget<Z>

java.lang.Object
com.bumptech.glide.request.target.CustomTarget<Z>
com.bumptech.glide.request.target.PreloadTarget<Z>
Type Parameters:
Z - The type of resource that will be loaded into memory.
All Implemented Interfaces:
LifecycleListener, Target<Z>

public final class PreloadTarget<Z> extends CustomTarget<Z>
A one time use Target class that loads a resource into memory and then clears itself.
  • Method Details

    • obtain

      public static <Z> PreloadTarget<Z> obtain(RequestManager requestManager, int width, int height)
      Returns a PreloadTarget.
      Type Parameters:
      Z - The type of the desired resource.
      Parameters:
      width - The width in pixels of the desired resource.
      height - The height in pixels of the desired resource.
    • onResourceReady

      public void onResourceReady(@NonNull Z resource, @Nullable Transition<? super Z> transition)
      Description copied from interface: Target
      The method that will be called when the resource load has finished.

      This may be called multiple times both within a single load and also across different loads if the Target object is re-used.

      Within a single load this may be called multiple times for reasons that include:

      • The load uses one or more thumbnails. Each time a thumbnail load completes successfully and no higher priority load has finished, this method will be called with the thumbnail resource. See RequestBuilder.thumbnail(com.bumptech.glide.RequestBuilder).
      • The load is paused and restarted. This can happen automatically in response to connectivity changes or the Activity / Fragment lifecycle. It can also happen if RequestManager.pauseRequests() is called manually.
      Parameters:
      resource - the loaded resource.
    • onLoadCleared

      public void onLoadCleared(@Nullable Drawable placeholder)
      Description copied from interface: Target
      A mandatory lifecycle callback that is called when a load is cancelled and its resources are freed.

      You must ensure that any current Drawable received in Target.onResourceReady(Object, Transition) is no longer used before redrawing the container (usually a View) or changing its visibility.

      Parameters:
      placeholder - The placeholder drawable to optionally show, or null.