示例#1
0
 /** 销毁Http请求框架,释放资源 */
 public static synchronized void destroy() {
   if (requestQueue != null) {
     requestQueue.stop();
     requestQueue = null;
   }
   ImageViewUtils.destroy();
 }
示例#2
0
 /** 初始化http请求框架 */
 public static synchronized void init(Context context) {
   if (requestQueue != null) {
     requestQueue.stop();
   }
   requestQueue = newRequestQueue(context);
   requestTag = requestTag == null ? new AtomicInteger() : requestTag;
   ImageViewUtils.init();
 }
示例#3
0
  /**
   * Starts the dispatchers in this queue.
   *
   * <p>start 方法中,开启一个缓存调度线程CacheDispatcher和 n 个网络调度线程NetworkDispatcher,这里 n 默认为4, 存在优化的余地,比如可以根据
   * CPU 核数以及网络类型计算更合适的并发数。 缓存调度线程不断的从缓存请求队列中取出 Request 去处理,网络调度线程不断的从网络请求队列中取出 Request 去处理。
   */
  public void start() {
    stop(); // Make sure any currently running dispatchers are stopped.
    // Create the cache dispatcher and start it.
    mCacheDispatcher = new CacheDispatcher(mCacheQueue, mNetworkQueue, mCache, mDelivery);
    mCacheDispatcher.start();

    // Create network dispatchers (and corresponding threads) up to the pool size.
    for (int i = 0; i < mDispatchers.length; i++) {
      NetworkDispatcher networkDispatcher =
          new NetworkDispatcher(mNetworkQueue, mNetwork, mCache, mDelivery);
      mDispatchers[i] = networkDispatcher;
      networkDispatcher.start();
    }
  }
 /** destroy volleytool */
 public void destroy() {
   queue.stop();
   queue = null;
   instance = null;
 }
 @Override
 protected void onDestroy() {
   super.onDestroy();
   mRequestQueue.stop();
 }
 @Override
 public void onDestroy() {
   super.onDestroy();
   mRequestQueue.stop();
 }