我正在使用经过改造的GET请求从服务器获取我的图像,并且正在使用Glide加载该图像。我想缓存这些图像,以防止下载相同的图像。
((我将图像ID发送到服务器,它在体内给出了图像。)
Bitmap bmp = BitmapFactory.decodeStream(response.body().byteStream());
Glide.with(getApplicationContext())
.load(bmp)
.signature(new ObjectKey(id))
.diskCacheStrategy(DiskCacheStrategy.AUTOMATIC)
.into(imgEvent);
使用DiskCacheStrategy.RESOURCE
避免多次从网络加载图像。
请参见https://futurestud.io/tutorials/glide-how-to-choose-the-best-caching-preference