设定档图片上传器并使用Picasso加载 [英] Profile Image Uploader and Load it with Picasso

查看:133
本文介绍了设定档图片上传器并使用Picasso加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有个人资料图片的android应用. 用户可以编辑他/她的个人资料图像. 我正在使用Picasso加载图像,但是每次加载个人资料图像时,Picasso都会加载旧图像.

I have an android app which has profile image. The user can edit his/her profile image. I'm using Picasso to load images, but every time I load profile image, Picasso loads old image.

当我上传个人资料图片时,我不会更改其网址,因此每个用户的个人资料图片网址都是恒定的.

When I upload profile image I don't change it's url, so profile image url for every user is constant.

第一个问题:每次用户更改个人资料图片时,我都应该更改个人资料图片网址吗?

First question: should I change profile image url every time user change profile image?

第二个问题:当用户更改个人资料图像时,我使Picasso无效,无法使用以下代码加载新图像:

Second question: When user change his/her profile image I invalidate Picasso to load new image using this code:

picassoInstance.load(url)
  .networkPolicy(NetworkPolicy.NO_CACHE)
  .transform(new CircleTransform())
  .placeholder(dr)
  .into(imageView);

但是毕加索给我看了旧的. 还有一件事: 我首先将图像URL加载到imageView中,而不先调用networkPolicy方法. 我应该如何处理这个问题?

But Picasso show me the old one. And one more thing: I load image url into imageView without calling networkPolicy method at first. How should I handle this problem?

推荐答案

每个图像都有不同的名称,每当上传新图像时,您都必须更新图像网址

Every Image has different name, whenever new image uploaded you have to update your image Url

例如当前网址: https://photographylife.com/nikon-d810-high-resolution-image-samples

其中图片名称为: nikon-d810-high-resolution-image-samples

,并且在上传新图像后,名称将不同.例如:image-sample

and after uploaded new image, name will be different for example : image-sample

因此您需要更新该图片网址: https://photographylife.com/image-sample 以新名称

尝试一下,我告诉你,因为我也希望这样做对你有帮助!

try this, i telling you cause im doing the same hope this will help you!

这篇关于设定档图片上传器并使用Picasso加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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