private RequestQueue newVolleyRequestQueueForTest(final Context context) { File cacheDir = new File(context.getCacheDir(), "cache/volley"); Network network = new BasicNetwork(new HurlStack()); ResponseDelivery responseDelivery = new ExecutorDelivery(Executors.newSingleThreadExecutor()); RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network, 4, responseDelivery); queue.start(); return queue; }
/** * 自定义Volley请求Queue * * @param context Context * @return RequestQueue */ public RequestQueue newRequestQueue(Context context) { File cacheDir = new File(context.getCacheDir(), DEFAULT_CACHE_DIR); Network network = new BasicNetwork(new HurlStack()); RequestQueue queue = new RequestQueue(new DiskBasedCache(cacheDir), network, DEFAULT_NETWORK_THREAD_POOL_SIZE, new ExecutorDelivery(executorService)); queue.start(); return queue; }
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(); }
/** * Creates the worker pool. Processing will not begin until {@link #start()} is called. * * @param cache A Cache to use for persisting responses to disk * @param network A Network interface for performing HTTP requests * @param threadPoolSize Number of network dispatcher threads to create */ public SmartRequestQueue(Cache cache, Network network, int threadPoolSize) { this(cache, network, threadPoolSize, new ExecutorDelivery(new Handler(Looper.getMainLooper()))); }