public class JsonAsyncHttpResponse extends AsyncHttpResponse
#onSuccess(int, org.json.JSONArray),
#onSuccess(int, org.json.JSONObject),
#onError(java.lang.Throwable, org.json.JSONArray),
#onError(java.lang.Throwable, org.json.JSONObject),
AsyncHttpResponse.onError(java.lang.Throwable, java.lang.String)| Modifier and Type | Field and Description |
|---|---|
protected static int |
FAIL_JSON
Indicate the response as a valid JSON and a fail message
|
protected static int |
SUCCESS_JSON
Indicate the response has a valid JSON and a success message
|
FAIL, FINISH, START, SUCCESS| Constructor and Description |
|---|
JsonAsyncHttpResponse() |
| Modifier and Type | Method and Description |
|---|---|
protected void |
handleErrorJsonMessage(java.lang.Throwable error,
java.lang.Object jsonResponse)
Handle the error json message and call the onError callback
|
boolean |
handleMessage(Message message) |
protected void |
handleSuccessJsonMessage(int stautusCode,
java.lang.Object jsonResponse)
Handle the success json message and call the onSuccess callback or the onError
|
void |
onError(java.lang.Throwable error,
JSONArray response)
Callback that indicate request has finished with a fail response
but a valid JSON body, this is util when you have a server that return a
valid JSON with the fail detail on the body but the response code >= 300
|
void |
onError(java.lang.Throwable error,
JSONObject response)
Callback that indicate request has finished with a fail response
but a valid JSON body, this is util when you have a server that return a
valid JSON with the fail detail on the body but the response code >= 300
|
void |
onSuccess(int statusCode,
JSONArray response)
Callback that indicate request has finished success
and its a JSONArray
|
void |
onSuccess(int statusCode,
JSONObject response)
Callback that indicate request has finished success
and its a JSONObject
|
protected void |
sendFailMessage(java.lang.Throwable error,
java.lang.String responseBody)
Send the fail message to the handler
|
protected void |
sendSuccessMessage(int statusCode,
java.lang.String responseBody)
Send the success message to the handler
|
handleFailMessage, handleSuccessMessage, obtainMessage, onFinish, onStart, sendEndMessage, sendMessage, sendStartMessageprotected static final int SUCCESS_JSON
protected static final int FAIL_JSON
public void onSuccess(int statusCode,
JSONObject response)
onSuccess in class AsyncHttpResponsestatusCode - the status code of the request normally 200response - the JSON response of this requestpublic void onSuccess(int statusCode,
JSONArray response)
onSuccess in class AsyncHttpResponsestatusCode - the status code of the request normally 200response - the JSON response of this requestpublic void onError(java.lang.Throwable error,
JSONArray response)
onError in class AsyncHttpResponseerror - the error stack trace of this responseresponse - the response of this requestAsyncHttpResponse.onError(java.lang.Throwable, java.lang.String)public void onError(java.lang.Throwable error,
JSONObject response)
onError in class AsyncHttpResponseerror - the error stack trace of this responseresponse - the response of this requestAsyncHttpResponse.onError(java.lang.Throwable, java.lang.String)protected void sendSuccessMessage(int statusCode,
java.lang.String responseBody)
AsyncHttpResponsesendSuccessMessage in class AsyncHttpResponsestatusCode - the success request status code (normally 200 or 202)responseBody - the response body of the request (if any) or nullprotected void sendFailMessage(java.lang.Throwable error,
java.lang.String responseBody)
AsyncHttpResponsesendFailMessage in class AsyncHttpResponseerror - the detail exception errorresponseBody - the request response body (if any) or nullpublic boolean handleMessage(Message message)
handleMessage in class AsyncHttpResponseprotected void handleErrorJsonMessage(java.lang.Throwable error,
java.lang.Object jsonResponse)
error - the stack trace of error messagejsonResponse - the json response to retrieve the instance#onError(java.lang.Throwable, org.json.JSONArray),
#onError(java.lang.Throwable, org.json.JSONObject)protected void handleSuccessJsonMessage(int stautusCode,
java.lang.Object jsonResponse)
stautsCode - the message status code of this requestjsonResponse - the response parsed ready to get instances#onSuccess(int, org.json.JSONObject),
#onSuccess(int, org.json.JSONArray),
AsyncHttpResponse.onError(java.lang.Throwable, java.lang.String)