Q - Request数据类型R - Response数据类型public class GsonRequest<Q,R> extends Request<R>
| 限定符和类型 | 类和说明 |
|---|---|
static interface |
GsonRequest.ResponseProcessor<R>
Response处理器。
|
Request.Method, Request.Priority| 限定符和类型 | 字段和说明 |
|---|---|
static String |
PROTOCOL_CHARSET |
static String |
PROTOCOL_CONTENT_TYPE |
| 构造器和说明 |
|---|
GsonRequest(String url,
Q requestObject,
Type responseType,
com.google.gson.Gson gson,
Response.Listener<R> listener,
Response.ErrorListener errorListener) |
GsonRequest(String url,
Q requestObject,
Type responseType,
Response.Listener<R> listener,
Response.ErrorListener errorListener) |
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
deliverResponse(R response)
Subclasses must implement this to perform delivery of the parsed
response to their listeners.
|
byte[] |
getBody()
Returns the raw POST or PUT body to be sent.
|
String |
getBodyContentType()
Returns the content type of the POST or PUT body.
|
protected Response<R> |
parseNetworkResponse(NetworkResponse response)
Subclasses must implement this to parse the raw network response
and return an appropriate response type.
|
void |
setResponseProcessor(GsonRequest.ResponseProcessor<R> processor) |
protected R |
toResponseValue(String json,
Type responseType) |
addMarker, cancel, compareTo, deliverError, getCacheEntry, getCacheKey, getErrorListener, getHeaders, getMethod, getParams, getParamsEncoding, getPostBody, getPostBodyContentType, getPostParams, getPostParamsEncoding, getPriority, getRetryPolicy, getSequence, getTag, getTimeoutMs, getTrafficStatsTag, getUrl, hasHadResponseDelivered, isCanceled, markDelivered, parseNetworkError, setCacheEntry, setRequestQueue, setRetryPolicy, setSequence, setShouldCache, setTag, shouldCache, toStringpublic GsonRequest(String url, Q requestObject, Type responseType, Response.Listener<R> listener, Response.ErrorListener errorListener)
url - requestObject - 要POST的数据responseType - Response数据要转成的对象类型listener - errorListener - public GsonRequest(String url, Q requestObject, Type responseType, com.google.gson.Gson gson, Response.Listener<R> listener, Response.ErrorListener errorListener)
url - requestObject - 要POST的数据responseType - Response数据要转成的对象类型gson - listener - errorListener - public String getBodyContentType()
RequestgetBodyContentType 在类中 Request<R>public byte[] getBody()
throws AuthFailureError
RequestBy default, the body consists of the request parameters in
application/x-www-form-urlencoded format. When overriding this method, consider overriding
Request.getBodyContentType() as well to match the new body format.
getBody 在类中 Request<R>AuthFailureError - in the event of auth failureprotected void deliverResponse(R response)
RequestdeliverResponse 在类中 Request<R>response - The parsed response returned by
Request.parseNetworkResponse(NetworkResponse)protected Response<R> parseNetworkResponse(NetworkResponse response)
RequestparseNetworkResponse 在类中 Request<R>response - Response from the networkprotected R toResponseValue(String json, Type responseType) throws Exception
Exceptionpublic void setResponseProcessor(GsonRequest.ResponseProcessor<R> processor)
Copyright © 2018. All rights reserved.