1

我有一个网格。每个项目有 2 个 ImageView。两个 ImageView 的加载图像相同,但在一个 ImageView 中,我想对位图应用转换。我可以只加载一次原始位图并缓存原始位图和转换后的位图(对于两个 Imageview)吗?

private DrawableRequestBuilder<String> mFullRequest;
private DrawableRequestBuilder<String> mBlurRequest;
...

//in my adapter constructor
mFullRequest = Glide.with(context)
        .fromString()
        .diskCacheStrategy(DiskCacheStrategy.ALL)
        .priority(Priority.HIGH)
        .crossFade(R.anim.fade_in, 150);
mBlurRequest = Glide.with(context)
        .fromString()
        .diskCacheStrategy(DiskCacheStrategy.RESULT)
        .transform(new BlurredImageTransformation(context))
        .crossFade();

.....
//in getview
final String imgUrl =.....
mFullRequest
        .load(imgUrl)
        .into(holder.campaignImage);

mBlurRequest
        .load(imgUrl)
        .override(Constants.MAX_BLURRED_IMAGE_WIDTH, (int) (Constants.MAX_BLURRED_IMAGE_WIDTH * ratio))
        .into(holder.blurredImage);
4

0 回答 0