com.android.volley.toolbox.BasicNetwork Java Examples
The following examples show how to use
com.android.volley.toolbox.BasicNetwork.
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: VolleyRequestPipeline.java From jus with Apache License 2.0 | 6 votes |
@Override public RequestPipeline prepare(States.GenericState state) { NetworkResponse resp = Util.newResponse(state); HttpResponse vResp = new BasicHttpResponse(new ProtocolVersion("HTTP", 1, 1), resp.statusCode, "OK"); vResp.setEntity(new ByteArrayEntity(resp.data)); for(String h:resp.headers.names()) { vResp.setHeader(h,resp.headers.get(h)); } MockVolleyHttpStack stack = new MockVolleyHttpStack(); stack.setResponseToReturn(vResp); this.requestQueue = new com.android.volley.RequestQueue( new VolleyNoCache(), new BasicNetwork(stack), state.concurrencyLevel ); requestQueue.start(); return this; }
Example #2
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 #3
Source File: VolleyQueueSingleton.java From base-module with Apache License 2.0 | 5 votes |
private RequestQueue newAsyncRequestQueue(HurlStack stack) { BasicNetwork network = new BasicNetwork(stack); //修改Volley的请求队列,构键新的线程池 RequestQueue queue1 = new RequestQueue(new NoCache(), network, DEFAULT_NETWORK_THREAD_POOL_SIZE, new ExecutorDelivery(executorService)); queue1.start(); return queue1; }
Example #4
Source File: LimitingRequestQueue.java From odyssey with GNU General Public License v3.0 | 5 votes |
public synchronized static LimitingRequestQueue getInstance(Context context) { if (null == mInstance) { Network network = new BasicNetwork(new HurlStack()); // 10MB disk cache Cache cache = new DiskBasedCache(context.getCacheDir(), 1024 * 1024 * 10); mInstance = new LimitingRequestQueue(cache, network); mInstance.start(); } return mInstance; }
Example #5
Source File: ImageLoader.java From android-discourse with Apache License 2.0 | 5 votes |
private static RequestQueue newRequestQueue(Context context) { // On HC+ use HurlStack which is based on HttpURLConnection. Otherwise fall back on // AndroidHttpClient (based on Apache DefaultHttpClient) which should no longer be used // on newer platform versions where HttpURLConnection is simply better. Network network = new BasicNetwork(Utils.hasHoneycomb() ? new HurlStack() : new HttpClientStack(AndroidHttpClient.newInstance(Utils.getUserAgent(context)))); Cache cache = new DiskBasedCache(getDiskCacheDir(context, CACHE_DIR), DEFAULT_DISK_USAGE_BYTES); RequestQueue queue = new RequestQueue(cache, network); queue.start(); return queue; }
Example #6
Source File: WaspTest.java From wasp with Apache License 2.0 | 5 votes |
public WaspTest() throws Exception { File cacheDir = new File(context.getCacheDir(), "volley"); Network network = new BasicNetwork(new OkHttpStack(new OkHttpClient())); ResponseDelivery delivery = new ExecutorDelivery(executor); requestQueue = new RequestQueue(new DiskBasedCache(cacheDir), network, 4, delivery); requestQueue.start(); server.start(); }
Example #7
Source File: VolleyTestMainActivity.java From android_tv_metro with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.test_main); txtDisplay = (TextView) findViewById(R.id.txtDisplay); // Instantiate the cache Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap // Set up the network to use HttpURLConnection as the HTTP client. Network network = new BasicNetwork(new HurlStack()); // Instantiate the RequestQueue with the cache and network. mRequestQueue = new RequestQueue(cache, network); // Start the queue mRequestQueue.start(); String url = "http://172.27.9.104:9300/testdata/1/1/1/zh/CN?api=index"; JsonObjectRequest jsObjRequest = new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { // TODO Auto-generated method stub txtDisplay.setText("Response => " + response.toString()); findViewById(R.id.progressBar1).setVisibility(View.GONE); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { txtDisplay.setText("VolleyError => " + error.toString()); findViewById(R.id.progressBar1).setVisibility(View.GONE); } }); mRequestQueue.add(jsObjRequest); }
Example #8
Source File: RemoteDataSource.java From android-network-security-config with Apache License 2.0 | 4 votes |
public RemoteDataSource(String url) { mUrl = url; mRequestQueue = new RequestQueue(new NoCache(), new BasicNetwork(new HurlStack())); mRequestQueue.start(); }
Example #9
Source File: GetChromium.java From getChromium with GNU General Public License v3.0 | 4 votes |
private void downloadLatest() { // Instantiate the cache Cache cache = new DiskBasedCache(getCacheDir(), 1024 * 1024); // 1MB cap // Set up the network to use HttpURLConnection as the HTTP client. com.android.volley.Network network = new BasicNetwork(new HurlStack()); // Instantiate the RequestQueue with the cache and network. mRequestQueue = new RequestQueue(cache, network); mRequestQueue.start(); // Request a string response from "https://commondatastorage.googleapis.com/chromium-browser-snapshots/Android/LAST_CHANGE" // The response provides the current build number of Chromium's latest build String urlL = "https://commondatastorage.googleapis.com/chromium-browser-snapshots/Android/LAST_CHANGE"; final StringRequest stringRequest = new StringRequest(Request.Method.GET, urlL, new Response.Listener<String>() { @Override public void onResponse(String response) { // Build new String for the current APK download URL Uri.Builder builder = new Uri.Builder(); builder.scheme("https") .authority("commondatastorage.googleapis.com") .appendPath("chromium-browser-snapshots") .appendPath("Android") .appendPath(response) // Build revision number .appendPath("chrome-android.zip"); // Name of the file that will contain the APKs. String apkUrl = builder.build().toString(); new DownloadTask().execute(apkUrl); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } }); // Add the request to the RequestQueue. mRequestQueue.add(stringRequest); }
Example #10
Source File: FakeRequestQueue.java From openshop.io-android with MIT License | 4 votes |
public FakeRequestQueue(Context context) { super(new NoCache(), new BasicNetwork(new FakeHttpStack(context))); start(); }
Example #11
Source File: DefaultCrossbowComponents.java From CrossBow with Apache License 2.0 | 4 votes |
public Network onCreateNetwork(HttpStack httpStack) { return new BasicNetwork(httpStack); }
Example #12
Source File: ConfigUtils.java From Volley-Ball with MIT License | 4 votes |
public static Network getDefaultNetwork(HttpStack httpStack) { return new BasicNetwork(httpStack); }
Example #13
Source File: ConfigUtils.java From Volley-Ball with MIT License | 4 votes |
public static Network getDefaultNetworkWithDefaultHttpStack(Context context) { return new BasicNetwork(getDefaultHttpStack(context)); }