daimajia / AndroidImageSlider

An amazing and convenient Android image slider.
MIT License
5.62k stars 1.66k forks source link

https url #368

Open Arunkrishna008 opened 6 years ago

Arunkrishna008 commented 6 years ago

can't load https url images. then i create class like private PicassoTrustAll(Context context) { OkHttpClient client = new OkHttpClient(); client.setHostnameVerifier(new HostnameVerifier() { @Override public boolean verify(String s, SSLSession sslSession) { return true; } }); TrustManager[] trustAllCerts = new TrustManager[] { new X509TrustManager() { @Override public void checkClientTrusted( java.security.cert.X509Certificate[] x509Certificates, String s) throws java.security.cert.CertificateException { }

        @Override
        public void checkServerTrusted(
                java.security.cert.X509Certificate[] x509Certificates,
                String s) throws java.security.cert.CertificateException {
        }

        @Override
        public java.security.cert.X509Certificate[] getAcceptedIssuers() {
            return new java.security.cert.X509Certificate[] {};
        }
    } };
    try {
        SSLContext sc = SSLContext.getInstance("TLS");
        sc.init(null, trustAllCerts, new java.security.SecureRandom());
        client.setSslSocketFactory(sc.getSocketFactory());
    } catch (Exception e) {
        e.printStackTrace();
    }

    mInstance = new Picasso.Builder(context)
            .downloader(new OkHttpDownloader(client))
            .listener(new Picasso.Listener() {
                @Override
                public void onImageLoadFailed(Picasso picasso, Uri uri, Exception exception) {
                   // Log.e("PICASSO", exception);
                }
            }).build();

}

public static Picasso getInstance(Context context) {
    if (mInstance == null) {
        new PicassoTrustAll(context);
    }
    return mInstance;
}

}

but i cant implement this class in baseslider