Class 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 Detail

      • 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.
        Parameters:
        resource - the loaded resource.
      • onLoadCleared

        public void onLoadCleared​(@Nullable
                                  android.graphics.drawable.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.