/** * Uses Glide to load a gif or image into an ImageView * * @param weakRef the {@link WeakReference} of a given subclass of {@link Context} * @param params the {@link GlideTaskParams} */ public static <CTX extends Context, T extends ImageView> void loadGif(@NonNull WeakReference<CTX> weakRef, @NonNull GlideTaskParams<T> params) { if (!AbstractWeakReferenceUtils.isAlive(weakRef)) { return; } GifRequestBuilder<String> requestBuilder = Glide.with(weakRef.get()).load(params.getPath()).asGif() .diskCacheStrategy(DiskCacheStrategy.ALL); load(applyDimens(requestBuilder, params), params); }
/** * gif图片显示 */ private static GifRequestBuilder<String> baseGif(ImageView iv, String key){ return Glide.with(iv.getContext()) .load(key) .asGif() .crossFade(150) .diskCacheStrategy(DiskCacheStrategy.SOURCE) .placeholder(getRandomColor()); }