毕加索是否无法从http网址加载图片,但会从https网址加载图片? [英] Picasso not loading image from http url but loads images from https url?

查看:108
本文介绍了毕加索是否无法从http网址加载图片,但会从https网址加载图片?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

毕加索(Picasso)如果图像来自https网址,则可以很好地加载图像,例如:https://i.ytimg.com/vi/28uUsJ72a1A/hqdefault.jpg

Picasso Loads the image fine if its from a https url like: https://i.ytimg.com/vi/28uUsJ72a1A/hqdefault.jpg

由于youtube通过https引导所有流量,因此可以实现以下目的: http://i.ytimg.com/vi/28uUsJ72a1A/hqdefault.jpg

Since youtube directs all traffic through https this works to: http://i.ytimg.com/vi/28uUsJ72a1A/hqdefault.jpg

但是当我使用我的网址时 http://www.example.com/images/djnsdfndsf.jpg

But when I use my url http://www.example.com/images/djnsdfndsf.jpg

它重新链接到该网站的https版本的链接,只是给出了一个错误

it redircets the link to a https version of the site and just gives a error

这就是我加载图像的方式 Picasso.with(this).load(current.getImageURL()).into(ImageView);

This is how i'm loading the images Picasso.with(this).load(current.getImageURL()).into(ImageView);

So I tried using this:
//Below code for Picasso initializing once for the app
private Picasso picasso;
private OkHttpClient okHttpClient;

okHttpClient = new OkHttpClient();
picasso = new Picasso.Builder(this)
                .downloader(new OkHttpDownloader(okHttpClient))
                .build();

//Below code to retrieve the images whereever required on the app
picasso.with(this).load(current.getImageURL()).into(imageView)

但是上面的代码给出了无法解析OkHttpDownloader

But Above code gives cannot resolve OkHttpDownloader

现在我正在使用compile 'com.squareup.picasso:picasso:2.5.2'

编辑 如何强制Picasso通过http而不是https下载它?

EDIT How do I force Picasso to download it over http not https?

推荐答案

只需尝试以下操作:

在您的URL中将http替换为https.

String aUrl = aImageInfo.getImage_url().replace("http", "https");

    Picasso
            .with(myContext)
            .load(aUrl)
            .placeholder(R.mipmap.place_holder)
            .error(R.mipmap.error)
            .fit()
            .into(aHolder.aImageView);

这篇关于毕加索是否无法从http网址加载图片,但会从https网址加载图片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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