毕加索不加载HTTP Facebook链接(不重复)



在将问题/问题设置为重复之前,请先阅读所有内容。

我知道这是一个已知问题,Stackoverflow上有很多问题,Github上有很多问题,但相信我,我都尝试过了。

问题

未加载此链接:

https://scontent.xx.fbcdn.net/v/t1.0-1/p200x200/13872950_1066865640060722_8272182690153279858_n.jpg?oh=66a4ff80019c1fbf79bee45d32f03468&oe=59F65F50

我的代码

Target target = new Target() {
@Override
public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) {
userPicture.setImageDrawable(FunctionUtil.roundBitmap(bitmap));
}
@Override
public void onBitmapFailed(Drawable errorDrawable) {
Resources resources = getContext().getResources();
Bitmap bitmap = BitmapFactory.decodeResource(resources, R.drawable.ic_image_content_error);
userPicture.setImageDrawable(FunctionUtil.roundBitmap(bitmap));
}
@Override
public void onPrepareLoad(Drawable placeHolderDrawable) {
Resources resources = getContext().getResources();
Bitmap bitmap = BitmapFactory.decodeResource(resources, R.drawable.ic_image_placeholder);
userPicture.setImageDrawable(FunctionUtil.roundBitmap(bitmap));
}
};
Picasso.with(getContext()).load(me.getPicture().getUrl()).into(target);

我试过什么

无缓存:Picasso.with(getContext()).load(me.getPicture().getUrl()).memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE).into(target);

新下载器:

`new Picasso.Builder(getContext()).downloader(new OkHttpDownloader(getContext())).build().load(me.getPicture().getUrl()).into(target);`

双:

`new Picasso.Builder(getContext()).downloader(new OkHttpDownloader(getContext())).build().load(me.getPicture().getUrl()).memoryPolicy(MemoryPolicy.NO_CACHE).networkPolicy(NetworkPolicy.NO_CACHE).into(target);`

我做错了什么?

好的,所以这个问题在这里得到了回答:

https://github.com/square/picasso/issues/1658

我的错误是将目标创建为本地方法属性,然后当毕加索花费更多时间来加载图像时,垃圾收集器可能会清理目标引用,这使得毕加索无法将其加载到目标中。这就是为什么它有时有效。

溶液

将目标对象创建为活动内的全局属性,以保留其引用,只要您使用要将图像加载到的 imageView。这解决了问题。:)

谢谢大家!

最新更新