com.duowan.mobile.netroid.request
Class JsonObjectRequest

java.lang.Object
  extended by com.duowan.mobile.netroid.Request<T>
      extended by com.duowan.mobile.netroid.request.JsonRequest<org.json.JSONObject>
          extended by com.duowan.mobile.netroid.request.JsonObjectRequest
All Implemented Interfaces:
java.lang.Comparable<Request<org.json.JSONObject>>

public class JsonObjectRequest
extends JsonRequest<org.json.JSONObject>

A request for retrieving a JSONObject response body at a given URL, allowing for an optional JSONObject to be passed in as part of the request body.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.duowan.mobile.netroid.Request
Request.Method, Request.Priority
 
Constructor Summary
JsonObjectRequest(int method, java.lang.String url, org.json.JSONObject jsonRequest, Listener<org.json.JSONObject> listener)
          Creates a new request.
JsonObjectRequest(java.lang.String url, org.json.JSONObject jsonRequest, Listener<org.json.JSONObject> listener)
          Constructor which defaults to GET if jsonRequest is null, POST otherwise.
 
Method Summary
protected  Response<org.json.JSONObject> parseNetworkResponse(NetworkResponse response)
          Subclasses must implement this to parse the raw network response and return an appropriate response type.
 
Methods inherited from class com.duowan.mobile.netroid.request.JsonRequest
getBody, getBodyContentType
 
Methods inherited from class com.duowan.mobile.netroid.Request
addHeader, addMarker, cancel, compareTo, deliverCancel, deliverDownloadProgress, deliverError, deliverFinish, deliverNetworking, deliverPreExecute, deliverRetry, deliverSuccess, deliverUsedCache, finish, getCacheExpireTime, getCacheKey, getHeaders, getMethod, getParams, getParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getUrl, handleResponse, hasHadResponseDelivered, isCanceled, isForceUpdate, markDelivered, parseNetworkError, perform, prepare, removeHeader, setCacheExpireTime, setForceUpdate, setListener, setRequestQueue, setRetryPolicy, setSequence, setTag, shouldCache, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JsonObjectRequest

public JsonObjectRequest(int method,
                         java.lang.String url,
                         org.json.JSONObject jsonRequest,
                         Listener<org.json.JSONObject> listener)
Creates a new request.

Parameters:
method - the HTTP method to use
url - URL to fetch the JSON from
jsonRequest - A JSONObject to post with the request. Null is allowed and indicates no parameters will be posted along with request.
listener - Listener to receive the JSON response or error message

JsonObjectRequest

public JsonObjectRequest(java.lang.String url,
                         org.json.JSONObject jsonRequest,
                         Listener<org.json.JSONObject> listener)
Constructor which defaults to GET if jsonRequest is null, POST otherwise.

See Also:
JsonObjectRequest(int, String, JSONObject, Listener)
Method Detail

parseNetworkResponse

protected Response<org.json.JSONObject> parseNetworkResponse(NetworkResponse response)
Description copied from class: Request
Subclasses must implement this to parse the raw network response and return an appropriate response type. This method will be called from a worker thread. The response will not be delivered if you return null.

Specified by:
parseNetworkResponse in class JsonRequest<org.json.JSONObject>
Parameters:
response - Response from the network
Returns:
The parsed response, or null in the case of an error