使用 Glide 无法刷新验证码图像 [英] Captcha image cannot be refresh by using Glide

查看:31
本文介绍了使用 Glide 无法刷新验证码图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用 Glide 将 Captcha 图像加载到 ImageView 中.第一次加载没问题.但是,当我将验证码图像重新加载到同一个 ImageView 中时,ImageView 不会刷新到新图像.有谁知道如何解决这个问题?

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);

推荐答案

您始终可以使用 Glide.clear() 然后再次调用 Glide.with(...).load() .如果图片改变时你的 url 没有改变,你可能还需要添加 .skipMemoryCache(true) 到您的加载调用.如需更多控制,请查看 .signature() API.您可以随时执行以下操作:

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);

这篇关于使用 Glide 无法刷新验证码图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆