com.android.volley.ExecutorDelivery Java Examples

The following examples show how to use com.android.volley.ExecutorDelivery. 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: VolleyQueueSingleton.java    From base-module with Apache License 2.0 5 votes vote down vote up
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 #2
Source File: WaspTest.java    From wasp with Apache License 2.0 5 votes vote down vote up
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 #3
Source File: MultiPartRequest.java    From volley with Apache License 2.0 5 votes vote down vote up
public MultiPartRequest(int method, String url, Listener<T> listener, ErrorListener errorlistener, LoadingListener loadingListener) {

        super(method, url, errorlistener);
        mListener = listener;
        
        mMultipartEntity = new UploadMultipartEntity();
        
        final ExecutorDelivery delivery = new ExecutorDelivery(new Handler(Looper.getMainLooper()));
        setLoadingListener(loadingListener);
        if (loadingListener != null) {
            mMultipartEntity.setListener(new ProgressListener() {
                long time = SystemClock.uptimeMillis();
                long count = -1;
                
                @Override
                public void transferred(long num) {
                    if (count == -1) {
                        count = mMultipartEntity.getContentLength();
                    }
                    // LogUtils.d("bacy", "upload->" + count + ",num->" + num);
                    long thisTime = SystemClock.uptimeMillis();
                    if (thisTime - time >= getRate() || count == num) {
                        time = thisTime;
                        delivery.postLoading(MultiPartRequest.this, count, num);
                    }
                }
            });
        }
        setRetryPolicy(new DefaultRetryPolicy(TIMEOUT_MS, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    }