Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Captcha image cannot be refresh by using Glide

I have tried to use Glide to load an Captcha image into a ImageView. The first time loading is fine. However, when I reload the Captcha image into the same ImageView, the ImageView does not refresh to new image. Does anyone have idea how to solve this issue?

String url = "https://captcha_path";
ImageView imgView = (ImageView)getActivity().findViewById(R.id.imgView);

Glide.with(getActivity()).load(url).asBitmap().diskCacheStrategy(DiskCacheStrategy.NONE).into(imgView);
like image 429
user3288747 Avatar asked Nov 10 '14 03:11

user3288747


1 Answers

You can always use Glide.clear() and then call Glide.with(...).load() again. If your url doesn't change when the image changes, you may also need to add .skipMemoryCache(true) to your load call. For more control, check out the .signature() API. You can always do something like:

Glide.with(fragment)
    .load(url)
    .signature(new StringSignature(UUID.randomUUID().toString()))
    .into(imgView);
like image 131
Sam Judd Avatar answered Oct 24 '22 04:10

Sam Judd