1 package com.bumptech.glide.request.target; 2 3 import com.bumptech.glide.Glide; 4 import com.bumptech.glide.request.animation.GlideAnimation; 5 6 /** 7 * A one time use {@link com.bumptech.glide.request.target.Target} class that loads a resource into memory and then 8 * clears itself. 9 * 10 * @param <Z> The type of resource that will be loaded into memory. 11 */ 12 public final class PreloadTarget<Z> extends SimpleTarget<Z> { 13 14 /** 15 * Returns a PreloadTarget. 16 * 17 * @param width The width in pixels of the desired resource. 18 * @param height The height in pixels of the desired resource. 19 * @param <Z> The type of the desired resource. 20 */ 21 public static <Z> PreloadTarget<Z> obtain(int width, int height) { 22 return new PreloadTarget<Z>(width, height); 23 } 24 25 private PreloadTarget(int width, int height) { 26 super(width, height); 27 } 28 29 @Override 30 public void onResourceReady(Z resource, GlideAnimation<? super Z> glideAnimation) { 31 Glide.clear(this); 32 } 33 } 34