Update volley

captchafix
Florens Douwes 11 years ago
parent 98440a97ef
commit d3784fc4cc
  1. 4
      Clover/app/src/main/java/com/android/volley/NetworkDispatcher.java
  2. 4
      Clover/app/src/main/java/com/android/volley/RequestQueue.java
  3. 36
      Clover/app/src/main/java/com/android/volley/toolbox/BasicNetwork.java
  4. 33
      Clover/app/src/main/java/com/android/volley/toolbox/DiskBasedCache.java
  5. 2
      Clover/app/src/main/java/com/android/volley/toolbox/HurlStack.java
  6. 3
      Clover/app/src/main/java/com/android/volley/toolbox/ImageLoader.java

@ -16,13 +16,13 @@
package com.android.volley;
import java.util.concurrent.BlockingQueue;
import android.annotation.TargetApi;
import android.net.TrafficStats;
import android.os.Build;
import android.os.Process;
import java.util.concurrent.BlockingQueue;
/**
* Provides a thread for performing network dispatch from a queue of requests.
*

@ -171,7 +171,7 @@ public class RequestQueue {
}
/**
* A simple predicate or setFilter interface for Requests, for use by
* A simple predicate or filter interface for Requests, for use by
* {@link RequestQueue#cancelAll(RequestFilter)}.
*/
public interface RequestFilter {
@ -179,7 +179,7 @@ public class RequestQueue {
}
/**
* Cancels all requests in this queue for which the given setFilter applies.
* Cancels all requests in this queue for which the given filter applies.
* @param filter The filtering function to use
*/
public void cancelAll(RequestFilter filter) {

@ -16,23 +16,6 @@
package com.android.volley.toolbox;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.cookie.DateUtils;
import org.floens.chan.utils.Logger;
import android.os.SystemClock;
import com.android.volley.AuthFailureError;
@ -48,6 +31,22 @@ import com.android.volley.TimeoutError;
import com.android.volley.VolleyError;
import com.android.volley.VolleyLog;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.StatusLine;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.impl.cookie.DateUtils;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.SocketTimeoutException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* A network performing Volley requests over an {@link HttpStack}.
*/
@ -223,9 +222,6 @@ public class BasicNetwork implements Network {
bytes.write(buffer, 0, count);
}
return bytes.toByteArray();
} catch (OutOfMemoryError e) {
Logger.e("Volley BasicNetwork", "Should not happen!", e);
return new byte[0];
} finally {
try {
// Close the InputStream and release the resources by "consuming the content".

@ -16,6 +16,11 @@
package com.android.volley.toolbox;
import android.os.SystemClock;
import com.android.volley.Cache;
import com.android.volley.VolleyLog;
import java.io.EOFException;
import java.io.File;
import java.io.FileInputStream;
@ -30,11 +35,6 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import android.os.SystemClock;
import com.android.volley.Cache;
import com.android.volley.VolleyLog;
/**
* Cache implementation that caches files directly onto the hard disk in the specified
* directory. The default disk usage size is 5MB, but is configurable.
@ -55,13 +55,13 @@ public class DiskBasedCache implements Cache {
private final int mMaxCacheSizeInBytes;
/** Default maximum disk usage in bytes. */
private static final int DEFAULT_DISK_USAGE_BYTES = 50 * 1024 * 1024;
private static final int DEFAULT_DISK_USAGE_BYTES = 5 * 1024 * 1024;
/** High water mark percentage for the cache */
private static final float HYSTERESIS_FACTOR = 0.9f;
/** Magic number for current version of cache file format. */
private static final int CACHE_MAGIC = 0x20120504;
private static final int CACHE_MAGIC = 0x20140623;
/**
* Constructs an instance of the DiskBasedCache at the specified directory.
@ -197,7 +197,12 @@ public class DiskBasedCache implements Cache {
try {
FileOutputStream fos = new FileOutputStream(file);
CacheHeader e = new CacheHeader(key, entry);
e.writeHeader(fos);
boolean success = e.writeHeader(fos);
if (!success) {
fos.close();
VolleyLog.d("Failed to write header for %s", file.getAbsolutePath());
throw new IOException();
}
fos.write(entry.data);
fos.close();
putEntry(key, e);
@ -361,12 +366,12 @@ public class DiskBasedCache implements Cache {
*/
public CacheHeader(String key, Entry entry) {
this.key = key;
size = entry.data.length;
etag = entry.etag;
serverDate = entry.serverDate;
ttl = entry.ttl;
softTtl = entry.softTtl;
responseHeaders = entry.responseHeaders;
this.size = entry.data.length;
this.etag = entry.etag;
this.serverDate = entry.serverDate;
this.ttl = entry.ttl;
this.softTtl = entry.softTtl;
this.responseHeaders = entry.responseHeaders;
}
/**

@ -223,8 +223,8 @@ public class HurlStack implements HttpStack {
connection.setRequestMethod("TRACE");
break;
case Method.PATCH:
addBodyIfExists(connection, request);
connection.setRequestMethod("PATCH");
addBodyIfExists(connection, request);
break;
default:
throw new IllegalStateException("Unknown method type.");

@ -474,6 +474,7 @@ public class ImageLoader {
* @param maxHeight The max-height of the output.
*/
private static String getCacheKey(String url, int maxWidth, int maxHeight) {
return "#W" + maxWidth + "#H" + maxHeight + url;
return new StringBuilder(url.length() + 12).append("#W").append(maxWidth)
.append("#H").append(maxHeight).append(url).toString();
}
}

Loading…
Cancel
Save