com.android.volley.toolbox.HttpStack Java Examples
The following examples show how to use
com.android.volley.toolbox.HttpStack.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CloudBackendFragment.java From io2014-codelabs with Apache License 2.0 | 6 votes |
private RequestQueue newRequestQueue(Context context) { // define cache folder File rootCache = context.getExternalCacheDir(); if (rootCache == null) { rootCache = context.getCacheDir(); } File cacheDir = new File(rootCache, DEFAULT_CACHE_DIR); cacheDir.mkdirs(); HttpStack stack = new HurlStack(); Network network = new BasicNetwork(stack); DiskBasedCache diskBasedCache = new DiskBasedCache(cacheDir, DEFAULT_DISK_USAGE_BYTES); RequestQueue queue = new RequestQueue(diskBasedCache, network); queue.start(); return queue; }
Example #2
Source File: FileMockNetwork.java From Volley-Ball with MIT License | 5 votes |
public FileMockNetwork(Context context, Config config) { mContext = context; mConfig = config; // configure the real network for non mocked requests if (config.mRealNetwork == null) { HttpStack httpStack = (config.mRealNetworkHttpStack == null) ? ConfigUtils.getDefaultHttpStack(mContext) : config.mRealNetworkHttpStack; config.mRealNetwork = ConfigUtils.getDefaultNetwork(httpStack); } if (!mConfig.mBasePath.equals("") && !mConfig.mBasePath.endsWith("/")) { mConfig.mBasePath += "/"; } }
Example #3
Source File: WaspBuilderTest.java From wasp with Apache License 2.0 | 5 votes |
@Test public void testWaspHttpStackCustom() throws Exception { class MyHttpStack implements WaspHttpStack { @Override public HttpStack getHttpStack() { return new OkHttpStack(new OkHttpClient()); } @Override public void setHostnameVerifier(HostnameVerifier hostnameVerifier) { } @Override public void setSslSocketFactory(SSLSocketFactory sslSocketFactory) { } @Override public void setCookieHandler(CookieHandler cookieHandler) { } } Wasp.Builder builder = new Wasp.Builder(context) .setWaspHttpStack(new MyHttpStack()) .setEndpoint("http"); builder.build(); //default should be NONE assertThat(builder.getWaspHttpStack()).isInstanceOf(MyHttpStack.class); }
Example #4
Source File: HttpStackSelector.java From CrossBow with Apache License 2.0 | 5 votes |
public static HttpStack createStack() { if(hasOkHttp()) { OkHttpClient okHttpClient = new OkHttpClient(); VolleyLog.d("OkHttp found, using okhttp for http stack"); return new OkHttpStack(okHttpClient); } else if (useHttpClient()){ VolleyLog.d("Android version is older than Gingerbread (API 9), using HttpClient"); return new HttpClientStack(AndroidHttpClient.newInstance(USER_AGENT)); } else { VolleyLog.d("Using Default HttpUrlConnection"); return new HurlStack(); } }
Example #5
Source File: RestVolley.java From RestVolley with Apache License 2.0 | 4 votes |
public static RequestQueue newRequestQueue(Context context, HttpStack stack, int threadPoolSize) { return newRequestQueue(context, stack, -1, threadPoolSize); }
Example #6
Source File: JacksonNetwork.java From volley-jackson-extension with Apache License 2.0 | 4 votes |
/** * @param httpStack The HTTP stack that requests are performed with. */ public JacksonNetwork(HttpStack httpStack) { this(httpStack, DEFAULT_POOL_SIZE); }
Example #7
Source File: ConfigUtils.java From Volley-Ball with MIT License | 4 votes |
public static Network getDefaultNetwork(HttpStack httpStack) { return new BasicNetwork(httpStack); }
Example #8
Source File: VolleyBallConfig.java From Volley-Ball with MIT License | 4 votes |
public HttpStack getHttpStack() { return mHttpStack; }
Example #9
Source File: FileMockNetwork.java From Volley-Ball with MIT License | 4 votes |
public Config realNetworkHttpStack(HttpStack httpStack) { mRealNetworkHttpStack = httpStack; return this; }
Example #10
Source File: VolleyBall.java From VolleyBall with MIT License | 4 votes |
public VolleyBall(Context aContext, HttpStack aStack) { mContext = aContext.getApplicationContext(); mStack = aStack; mVolley = Volley.newRequestQueue(mContext, aStack); }
Example #11
Source File: WearCrossbowComponents.java From CrossBow with Apache License 2.0 | 4 votes |
@Override public Network onCreateNetwork(HttpStack httpStack) { return new PlayNetwork(getContext()); }
Example #12
Source File: DefaultCrossbowComponents.java From CrossBow with Apache License 2.0 | 4 votes |
public HttpStack onCreateHttpStack() { return HttpStackSelector.createStack(); }
Example #13
Source File: DefaultCrossbowComponents.java From CrossBow with Apache License 2.0 | 4 votes |
public Network onCreateNetwork(HttpStack httpStack) { return new BasicNetwork(httpStack); }
Example #14
Source File: RVNetwork.java From RestVolley with Apache License 2.0 | 4 votes |
/** * @param httpStack HTTP stack to be used * @param pool a buffer pool that improves GC performance in copy operations */ public RVNetwork(HttpStack httpStack, ByteArrayPool pool) { mHttpStack = httpStack; mPool = pool; }
Example #15
Source File: RVNetwork.java From RestVolley with Apache License 2.0 | 4 votes |
/** * @param httpStack HTTP stack to be used */ public RVNetwork(HttpStack httpStack) { // If a pool isn't passed in, then build a small default pool that will give us a lot of // benefit and not use too much memory. this(httpStack, new ByteArrayPool(DEFAULT_POOL_SIZE)); }
Example #16
Source File: StreamBasedNetwork.java From RestVolley with Apache License 2.0 | 4 votes |
/** * @param httpStack HTTP stack to be used */ public StreamBasedNetwork(HttpStack httpStack) { super(httpStack); }
Example #17
Source File: RestVolley.java From RestVolley with Apache License 2.0 | 4 votes |
public static RequestQueue newRequestQueue(Context context, HttpStack stack, int threadPoolSize, boolean isStreamBasedResponse) { return newRequestQueue(context, stack, -1, threadPoolSize, isStreamBasedResponse); }
Example #18
Source File: RestVolley.java From RestVolley with Apache License 2.0 | 4 votes |
public static RequestQueue newRequestQueue(Context context, HttpStack stack, int maxDiskCacheBytes, int threadPoolSize) { return newRequestQueue(context, stack, maxDiskCacheBytes, threadPoolSize, false); }
Example #19
Source File: JacksonNetwork.java From volley-jackson-extension with Apache License 2.0 | 2 votes |
/** * @param httpStack The HTTP stack that requests are performed with. * @param poolSize The size of the pool buffer used for cached requests. NOTE: caching * requests will have a significant adverse affect on parsing speed! */ public JacksonNetwork(HttpStack httpStack, int poolSize) { mHttpStack = httpStack; mPool = new ByteArrayPool(poolSize); }
Example #20
Source File: JacksonNetwork.java From volley-jackson-extension with Apache License 2.0 | 2 votes |
/** * Creates a default instance of the worker pool and calls {@link RequestQueue#start()} on it. * * @param context A {@link Context} to use for creating the cache dir. * @param stack An {@link com.android.volley.toolbox.HttpStack} to use for handling network calls * @return A started {@link RequestQueue} instance. */ public static RequestQueue newRequestQueue(Context context, HttpStack stack) { RequestQueue queue = new RequestQueue(new DiskBasedCache(new File(context.getCacheDir(), "volley")), new JacksonNetwork(stack)); queue.start(); return queue; }