aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/android/volley/toolbox/JsonRequest.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/com/android/volley/toolbox/JsonRequest.java')
-rw-r--r--src/main/java/com/android/volley/toolbox/JsonRequest.java34
1 files changed, 18 insertions, 16 deletions
diff --git a/src/main/java/com/android/volley/toolbox/JsonRequest.java b/src/main/java/com/android/volley/toolbox/JsonRequest.java
index f291076..fd395dd 100644
--- a/src/main/java/com/android/volley/toolbox/JsonRequest.java
+++ b/src/main/java/com/android/volley/toolbox/JsonRequest.java
@@ -16,18 +16,18 @@
package com.android.volley.toolbox;
+import android.support.annotation.GuardedBy;
import com.android.volley.NetworkResponse;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
import com.android.volley.VolleyLog;
-
import java.io.UnsupportedEncodingException;
/**
- * A request for retrieving a T type response body at a given URL that also
- * optionally sends along a JSON body in the request specified.
+ * A request for retrieving a T type response body at a given URL that also optionally sends along a
+ * JSON body in the request specified.
*
* @param <T> JSON type of response expected
*/
@@ -37,13 +37,14 @@ public abstract class JsonRequest<T> extends Request<T> {
/** Content type for request. */
private static final String PROTOCOL_CONTENT_TYPE =
- String.format("application/json; charset=%s", PROTOCOL_CHARSET);
+ String.format("application/json; charset=%s", PROTOCOL_CHARSET);
/** Lock to guard mListener as it is cleared on cancel() and read on delivery. */
private final Object mLock = new Object();
- // @GuardedBy("mLock")
+ @GuardedBy("mLock")
private Listener<T> mListener;
+
private final String mRequestBody;
/**
@@ -53,12 +54,16 @@ public abstract class JsonRequest<T> extends Request<T> {
* @deprecated Use {@link #JsonRequest(int, String, String, Listener, ErrorListener)}.
*/
@Deprecated
- public JsonRequest(String url, String requestBody, Listener<T> listener,
- ErrorListener errorListener) {
+ public JsonRequest(
+ String url, String requestBody, Listener<T> listener, ErrorListener errorListener) {
this(Method.DEPRECATED_GET_OR_POST, url, requestBody, listener, errorListener);
}
- public JsonRequest(int method, String url, String requestBody, Listener<T> listener,
+ public JsonRequest(
+ int method,
+ String url,
+ String requestBody,
+ Listener<T> listener,
ErrorListener errorListener) {
super(method, url, errorListener);
mListener = listener;
@@ -85,20 +90,16 @@ public abstract class JsonRequest<T> extends Request<T> {
}
@Override
- abstract protected Response<T> parseNetworkResponse(NetworkResponse response);
+ protected abstract Response<T> parseNetworkResponse(NetworkResponse response);
- /**
- * @deprecated Use {@link #getBodyContentType()}.
- */
+ /** @deprecated Use {@link #getBodyContentType()}. */
@Deprecated
@Override
public String getPostBodyContentType() {
return getBodyContentType();
}
- /**
- * @deprecated Use {@link #getBody()}.
- */
+ /** @deprecated Use {@link #getBody()}. */
@Deprecated
@Override
public byte[] getPostBody() {
@@ -115,7 +116,8 @@ public abstract class JsonRequest<T> extends Request<T> {
try {
return mRequestBody == null ? null : mRequestBody.getBytes(PROTOCOL_CHARSET);
} catch (UnsupportedEncodingException uee) {
- VolleyLog.wtf("Unsupported Encoding while trying to get the bytes of %s using %s",
+ VolleyLog.wtf(
+ "Unsupported Encoding while trying to get the bytes of %s using %s",
mRequestBody, PROTOCOL_CHARSET);
return null;
}