public class AsyncHttpResponse
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected static int |
FAIL
Indicate the response has failed
|
protected static int |
FINISH
Indicate the response has finished (after onSuccess or onError)
|
protected static int |
START
Indicate the response has started
|
protected static int |
SUCCESS
Indicate the response has finished with success
|
| Constructor and Description |
|---|
AsyncHttpResponse()
Construct a new instance of AsyncHttpResponse
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
handleFailMessage(java.lang.Throwable error,
java.lang.String responseBody)
Handle the fail message and call the relative callback
|
boolean |
handleMessage(Message message) |
protected void |
handleSuccessMessage(int statusCode,
java.lang.String responseBody)
Handle the success message and call the relative callback
|
protected Message |
obtainMessage(int responseMessage,
java.lang.Object response)
Obtain a handler thread message to verify the results
this method will always return a valid message
|
void |
onError(java.lang.Throwable error,
java.lang.String content)
Callback that indicate the request has return error
|
void |
onFinish()
Callback that indicate the request has finished
|
void |
onStart()
Callback that indicate the request has started
|
void |
onSuccess(int statusCode,
java.lang.String content)
Callback that indicate the request has
this method returns the content of the response
|
protected void |
sendEndMessage()
Send the handle message that indicate the request has finished
|
protected void |
sendFailMessage(java.lang.Throwable error,
java.lang.String content)
Send the fail message to the handler
|
protected void |
sendMessage(Message message)
Send a message over the handler,
if the handler is null no problems it will recreate it
|
protected void |
sendStartMessage()
Send the handle message that indicate the request has started
|
protected void |
sendSuccessMessage(int statusCode,
java.lang.String responseBody)
Send the success message to the handler
|
protected static final int SUCCESS
protected static final int FAIL
protected static final int START
protected static final int FINISH
public AsyncHttpResponse()
public void onStart()
public void onFinish()
public void onSuccess(int statusCode,
java.lang.String content)
statusCode - the request status code normally 200 or 202content - the request response bodypublic void onError(java.lang.Throwable error,
java.lang.String content)
error - a Exception class that indicate the errorcontent - the page error content if available or nullHttpRetryExceptionprotected void sendSuccessMessage(int statusCode,
java.lang.String responseBody)
statusCode - 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 content)
error - the detail exception errorcontent - the request response body (if any) or nullprotected void sendStartMessage()
protected void sendEndMessage()
protected void handleSuccessMessage(int statusCode,
java.lang.String responseBody)
statusCode - the request response status coderesponseBody - the request response body (if any) or nullprotected void handleFailMessage(java.lang.Throwable error,
java.lang.String responseBody)
error - the detail exceptionresponseBody - the response body of the request (if any) or nullonError(Throwable, String)public boolean handleMessage(Message message)
protected void sendMessage(Message message)
message - the message for send, can't be nullprotected Message obtainMessage(int responseMessage,
java.lang.Object response)
responseMessage - the response message identifierresponse - the response object to describle this message