Search in sources :

Example 1 with HurlStack

use of com.android.volley.toolbox.HurlStack in project AndroidNetworkDemo by dodocat.

the class RequestManager method newRequestQueue.

private RequestQueue newRequestQueue(Context context) {
    RequestQueue requestQueue;
    try {
        String[] hosts = { "kyfw.12306.cn" };
        int[] certRes = { R.raw.kyfw };
        String[] certPass = { "asdfqaz" };
        socketFactoryMap = new Hashtable<>(hosts.length);
        for (int i = 0; i < certRes.length; i++) {
            int res = certRes[i];
            String password = certPass[i];
            SSLSocketFactory sslSocketFactory = createSSLSocketFactory(context, res, password);
            socketFactoryMap.put(hosts[i], sslSocketFactory);
        }
        HurlStack stack = new SelfSignSslOkHttpStack(socketFactoryMap);
        requestQueue = Volley.newRequestQueue(context, stack);
        requestQueue.start();
    } catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | KeyManagementException | IOException e) {
        throw new RuntimeException(e);
    }
    return requestQueue;
}
Also used : HurlStack(com.android.volley.toolbox.HurlStack) CertificateException(java.security.cert.CertificateException) KeyStoreException(java.security.KeyStoreException) NoSuchAlgorithmException(java.security.NoSuchAlgorithmException) IOException(java.io.IOException) KeyManagementException(java.security.KeyManagementException) RequestQueue(com.android.volley.RequestQueue) SSLSocketFactory(javax.net.ssl.SSLSocketFactory)

Example 2 with HurlStack

use of com.android.volley.toolbox.HurlStack in project fresco by facebook.

the class SampleVolleyFactory method getRequestQueue.

public static RequestQueue getRequestQueue(Context context) {
    if (sRequestQueue == null) {
        File cacheDir = new File(context.getCacheDir(), VOLLEY_CACHE_DIR);
        sRequestQueue = new RequestQueue(new DiskBasedCache(cacheDir, ConfigConstants.MAX_DISK_CACHE_SIZE), new BasicNetwork(new HurlStack()));
        sRequestQueue.start();
    }
    return sRequestQueue;
}
Also used : BasicNetwork(com.android.volley.toolbox.BasicNetwork) HurlStack(com.android.volley.toolbox.HurlStack) RequestQueue(com.android.volley.RequestQueue) DiskBasedCache(com.android.volley.toolbox.DiskBasedCache) File(java.io.File)

Example 3 with HurlStack

use of com.android.volley.toolbox.HurlStack in project DesignLibrary by StylingAndroid.

the class VolleySingleton method getRequestQueue.

public RequestQueue getRequestQueue() {
    if (requestQueue == null) {
        Cache cache = new DiskBasedCache(context.getCacheDir(), CACHE_SIZE);
        Network network = new BasicNetwork(new HurlStack());
        requestQueue = new RequestQueue(cache, network);
        requestQueue.start();
    }
    return requestQueue;
}
Also used : BasicNetwork(com.android.volley.toolbox.BasicNetwork) HurlStack(com.android.volley.toolbox.HurlStack) RequestQueue(com.android.volley.RequestQueue) Network(com.android.volley.Network) BasicNetwork(com.android.volley.toolbox.BasicNetwork) DiskBasedCache(com.android.volley.toolbox.DiskBasedCache) Cache(com.android.volley.Cache) DiskBasedCache(com.android.volley.toolbox.DiskBasedCache)

Aggregations

RequestQueue (com.android.volley.RequestQueue)3 HurlStack (com.android.volley.toolbox.HurlStack)3 BasicNetwork (com.android.volley.toolbox.BasicNetwork)2 DiskBasedCache (com.android.volley.toolbox.DiskBasedCache)2 Cache (com.android.volley.Cache)1 Network (com.android.volley.Network)1 File (java.io.File)1 IOException (java.io.IOException)1 KeyManagementException (java.security.KeyManagementException)1 KeyStoreException (java.security.KeyStoreException)1 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)1 CertificateException (java.security.cert.CertificateException)1 SSLSocketFactory (javax.net.ssl.SSLSocketFactory)1