本文整理汇总了Java中com.android.volley.toolbox.ByteArrayPool类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayPool类的具体用法?Java ByteArrayPool怎么用?Java ByteArrayPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayPool类属于com.android.volley.toolbox包,在下文中一共展示了ByteArrayPool类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: entityToBytes
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
/** 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();
}
}
示例2: CastWebServer
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
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);
}
示例3: QMusicNetwork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
/**
* @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));
}
示例4: BaseNetwork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
/**
* @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));
}
示例5: DrBasicNetwork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
/**
* @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));
}
示例6: SBaseNetWork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
public SBaseNetWork(HttpStack httpStack, ByteArrayPool pool) {
super(httpStack, pool);
}
示例7: RVNetwork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
/**
* @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));
}
示例8: createNetwork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
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();
}
示例9: VolleyDiskCacheWrapper
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
public VolleyDiskCacheWrapper(DiskCache diskCache) {
this.diskCache = diskCache;
this.byteArrayPool = new ByteArrayPool(BYTE_POOL_SIZE);
}
示例10: OkNetwork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
/**
* @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));
}
示例11: BasicNetworkOOM
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
public BasicNetworkOOM(HttpStack httpStack, ByteArrayPool pool) {
super(httpStack, pool);
}
示例12: setByteArrayPool
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
public void setByteArrayPool(ByteArrayPool byteArrayPool) {
this.byteArrayPool = byteArrayPool;
}
示例13: JacksonNetwork
import com.android.volley.toolbox.ByteArrayPool; //导入依赖的package包/类
/**
* @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);
}