Java 类com.android.volley.toolbox.ByteArrayPool 实例源码

项目:RestVolley    文件:StreamBasedNetwork.java   
/** Reads the contents of HttpEntity into a byte[]. */
public static byte[] entityToBytes(InputStream inputStream, long contentLength, int bufferSize) throws IOException, ServerError {
    ByteArrayPool bytePool = new ByteArrayPool(bufferSize);
    PoolingByteArrayOutputStream bytes = new PoolingByteArrayOutputStream(bytePool, (int)contentLength);
    byte[] buffer = null;
    try {
        if (inputStream == null) {
            throw new ServerError();
        }
        buffer = bytePool.getBuf(1024);
        int count;
        while ((count = inputStream.read(buffer)) != -1) {
            bytes.write(buffer, 0, count);
        }
        return bytes.toByteArray();
    } finally {
        try {
            // Close the InputStream and release the resources by "consuming the content".
            inputStream.close();
        } catch (IOException e) {
            // This can happen if there was an exception above that left the entity in
            // an invalid state.
            VolleyLog.v("Error occured when calling consumingContent");
        }
        bytePool.returnBuf(buffer);
        bytes.close();
    }
}
项目:Orpheus    文件:CastWebServer.java   
public CastWebServer(Context context, String host, int port) {
    super(host, port);
    mContext = context;
    // get the lock
    mWifiLock = ((WifiManager) mContext.getSystemService(Context.WIFI_SERVICE)).createWifiLock(WifiManager.WIFI_MODE_FULL, "CastServer");
    mWifiLock.setReferenceCounted(false);
    // arbitrary size might increase as needed;
    mEtagCache = new LruCache<>(20);
    mBytePool = new ByteArrayPool(2*1024*1024);
}
项目:Qmusic    文件:QMusicNetwork.java   
/**
 * @param httpStack
 *            HTTP stack to be used
 */
public QMusicNetwork(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));
}
项目:GeekZone    文件:BaseNetwork.java   
/**
 * @param httpStack HTTP stack to be used
 */
public BaseNetwork(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));
}
项目:GeekZone    文件:BaseNetwork.java   
/**
 * @param httpStack HTTP stack to be used
 * @param pool      a buffer pool that improves GC performance in copy operations
 */
public BaseNetwork(HttpStack httpStack, ByteArrayPool pool) {
    mHttpStack = httpStack;
    mPool = pool;
}
项目:EsperantoRadio    文件:DrBasicNetwork.java   
/**
 * @param httpStack HTTP stack to be used
 */
public DrBasicNetwork(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));
}
项目:EsperantoRadio    文件:DrBasicNetwork.java   
/**
 * @param httpStack HTTP stack to be used
 * @param pool      a buffer pool that improves GC performance in copy operations
 */
public DrBasicNetwork(HttpStack httpStack, ByteArrayPool pool) {
  mHttpStack = httpStack;
  mPool = pool;
}
项目:MeifuGO    文件:SBaseNetWork.java   
public SBaseNetWork(HttpStack httpStack, ByteArrayPool pool) {
    super(httpStack, pool);
}
项目:RestVolley    文件:RVNetwork.java   
/**
 * @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));
}
项目:RestVolley    文件:RVNetwork.java   
/**
 * @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;
}
项目:FMTech    文件:FinskyApp.java   
private Network createNetwork()
{
  if (Utils.isBackgroundDataEnabled(this))
  {
    FinskyExperiments localFinskyExperiments = getExperiments();
    boolean bool = localFinskyExperiments.isEnabled(12603642L);
    int i;
    if ((localFinskyExperiments.isEnabled(12602748L)) || (localFinskyExperiments.isEnabled(12604235L)) || (localFinskyExperiments.isEnabled(12604236L))) {
      i = 1;
    }
    OkHttpClient localOkHttpClient;
    while ((GooglePlayServicesUtil.isSidewinderDevice(this)) || (((bool) || (i != 0)) && (((Boolean)G.enableOkHttp.get()).booleanValue())))
    {
      Protocol[] arrayOfProtocol = new Protocol[1];
      arrayOfProtocol[0] = Protocol.HTTP_1_1;
      ArrayList localArrayList = Lists.newArrayList(arrayOfProtocol);
      if (!bool) {
        localArrayList.add(Protocol.SPDY_3);
      }
      localOkHttpClient = new OkHttpClient();
      List localList = Util.immutableList(localArrayList);
      if (!localList.contains(Protocol.HTTP_1_1))
      {
        throw new IllegalArgumentException("protocols doesn't contain http/1.1: " + localList);
        i = 0;
      }
      else
      {
        if (localList.contains(Protocol.HTTP_1_0)) {
          throw new IllegalArgumentException("protocols must not contain http/1.0: " + localList);
        }
        if (localList.contains(null)) {
          throw new IllegalArgumentException("protocols must not contain null");
        }
        localOkHttpClient.protocols = Util.immutableList(localList);
        localOkHttpClient.followRedirects = false;
      }
    }
    for (Object localObject = new GoogleOkHttpStack(this, localOkHttpClient, new GoogleUrlRewriter(this), null, ((Boolean)G.enableSensitiveLogging.get()).booleanValue());; localObject = new GoogleHttpClientStack(this, ((Boolean)G.enableSensitiveLogging.get()).booleanValue())) {
      return new BasicNetwork((HttpStack)localObject, new ByteArrayPool(1024 * ((Integer)G.volleyBufferPoolSizeKb.get()).intValue()));
    }
  }
  return new DenyAllNetwork();
}
项目:saarang-iosched    文件:VolleyDiskCacheWrapper.java   
public VolleyDiskCacheWrapper(DiskCache diskCache) {
    this.diskCache = diskCache;
    this.byteArrayPool = new ByteArrayPool(BYTE_POOL_SIZE);
}
项目:AppDevFestSudeste2015    文件:VolleyDiskCacheWrapper.java   
public VolleyDiskCacheWrapper(DiskCache diskCache) {
    this.diskCache = diskCache;
    this.byteArrayPool = new ByteArrayPool(BYTE_POOL_SIZE);
}
项目:OkVolley    文件:OkNetwork.java   
/**
 * @param httpStack HTTP stack to be used
 */
public OkNetwork(OkStack 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));
}
项目:OkVolley    文件:OkNetwork.java   
/**
 * @param httpStack HTTP stack to be used
 * @param pool      a buffer pool that improves GC performance in copy operations
 */
public OkNetwork(OkStack httpStack, ByteArrayPool pool) {
    mHttpStack = httpStack;
    mPool = pool;
}
项目:cannon    文件:BasicNetworkOOM.java   
public BasicNetworkOOM(HttpStack httpStack, ByteArrayPool pool) {
    super(httpStack, pool);
}
项目:devfestnorte-app    文件:VolleyDiskCacheWrapper.java   
public VolleyDiskCacheWrapper(DiskCache diskCache) {
    this.diskCache = diskCache;
    this.byteArrayPool = new ByteArrayPool(BYTE_POOL_SIZE);
}
项目:saarang-iosched    文件:VolleyDiskCacheWrapper.java   
public VolleyDiskCacheWrapper(DiskCache diskCache) {
    this.diskCache = diskCache;
    this.byteArrayPool = new ByteArrayPool(BYTE_POOL_SIZE);
}
项目:CrossBow    文件:FileRequest.java   
public void setByteArrayPool(ByteArrayPool byteArrayPool) {
    this.byteArrayPool = byteArrayPool;
}
项目:volley-jackson-extension    文件:JacksonNetwork.java   
/**
 * @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);
}
项目:Qmusic    文件:QMusicNetwork.java   
/**
 * @param httpStack
 *            HTTP stack to be used
 * @param pool
 *            a buffer pool that improves GC performance in copy operations
 */
public QMusicNetwork(HttpStack httpStack, ByteArrayPool pool) {
    mHttpStack = httpStack;
    mPool = pool;
}