Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

glide force load cached image, don't care what resolution

I've been working on this for a while now and it is time to ask a SO question on it.

Find and load cached Image in Glide looks like it, but following the links and the discussion on Glide's page it doesn't work for me.

On Activity A, I load the image via an URL in an ImageView.

After that, I go offline with the device. Then I open Activity B, where I load the same URL in a different ImageView, which has other dimensions. It only works if the width and height are equal to the ImageView on Activity A, or you supply an override() with the width and height of that first ImageView. But Activity B does not know about that.

I do this in Activity A:

Glide.with(context)
    .load(url)
    .diskCacheStrategy(DiskCacheStrategy.ALL)
    .placeholder(R.drawable.placeholder)
    .crossFade()
    .into(image);

and in activity B I do:

Glide.with(mContext)
    .load(url)
    .override(Target.SIZE_ORIGINAL, Target.SIZE_ORIGINAL)
    .into(imageView);

I tried the above, because I thought the disk strategy will store the original too, so it will load that one than. Result is that no image is loaded.

I am thinking of going back to Picasso, because I think this is possible there, but I give Stackoverflow one more try.

I would throw in a bounty right away if that was possible...

like image 481
Boy Avatar asked Jan 22 '16 15:01

Boy


1 Answers

Can you try the following code for Activity B?

Glide.with(mContext)
   .load(url)
   .diskCacheStrategy(DiskCacheStrategy.SOURCE)
   .into(imageView);
like image 60
ap6491 Avatar answered Nov 13 '22 11:11

ap6491