public abstract class FileAsyncHttpResponseHandler extends AsyncHttpResponseHandler
| 限定符和类型 | 字段和说明 |
|---|---|
protected boolean |
append |
protected java.io.File |
mFile |
BUFFER_SIZE, CANCEL_MESSAGE, DEFAULT_CHARSET, FAILURE_MESSAGE, FINISH_MESSAGE, PROGRESS_MESSAGE, RETRY_MESSAGE, START_MESSAGE, SUCCESS_MESSAGE, UTF8_BOM| 构造器和说明 |
|---|
FileAsyncHttpResponseHandler(android.content.Context context)
Obtains new FileAsyncHttpResponseHandler against context with target being temporary file
|
FileAsyncHttpResponseHandler(java.io.File file)
Obtains new FileAsyncHttpResponseHandler and stores response in passed file
|
FileAsyncHttpResponseHandler(java.io.File file,
boolean append)
Obtains new FileAsyncHttpResponseHandler and stores response in passed file
|
| 限定符和类型 | 方法和说明 |
|---|---|
boolean |
deleteTargetFile()
Attempts to delete file with stored response
|
protected byte[] |
getResponseData(HttpEntity entity)
Returns byte array of response HttpEntity contents
|
protected java.io.File |
getTargetFile()
Retrieves File object in which the response is stored
|
protected java.io.File |
getTemporaryFile(android.content.Context context)
Used when there is no file to be used when calling constructor
|
void |
onFailure(int statusCode,
Header[] headers,
byte[] responseBytes,
java.lang.Throwable throwable)
Fired when a request fails to complete, override to handle in your own code
|
abstract void |
onFailure(int statusCode,
Header[] headers,
java.lang.Throwable throwable,
java.io.File file)
Method to be overriden, receives as much of file as possible Called when the file is
considered failure or if there is error when retrieving file
|
void |
onSuccess(int statusCode,
Header[] headers,
byte[] responseBytes)
Fired when a request returns successfully, override to handle in your own code
|
abstract void |
onSuccess(int statusCode,
Header[] headers,
java.io.File file)
Method to be overriden, receives as much of response as possible
|
getCharset, getRequestHeaders, getRequestURI, getUsePoolThread, getUseSynchronousMode, handleMessage, obtainMessage, onCancel, onFinish, onPostProcessResponse, onPreProcessResponse, onProgress, onRetry, onStart, onUserException, postRunnable, sendCancelMessage, sendFailureMessage, sendFinishMessage, sendMessage, sendProgressMessage, sendResponseMessage, sendRetryMessage, sendStartMessage, sendSuccessMessage, setCharset, setRequestHeaders, setRequestURI, setUsePoolThread, setUseSynchronousModepublic FileAsyncHttpResponseHandler(java.io.File file)
file - File to store response within, must not be nullpublic FileAsyncHttpResponseHandler(java.io.File file,
boolean append)
file - File to store response within, must not be nullappend - whether data should be appended to existing filepublic FileAsyncHttpResponseHandler(android.content.Context context)
context - Context, must not be nullpublic boolean deleteTargetFile()
protected java.io.File getTemporaryFile(android.content.Context context)
context - Context, must not be nullprotected java.io.File getTargetFile()
public final void onFailure(int statusCode,
Header[] headers,
byte[] responseBytes,
java.lang.Throwable throwable)
AsyncHttpResponseHandleronFailure 在类中 AsyncHttpResponseHandlerstatusCode - return HTTP status codeheaders - return headers, if anyresponseBytes - the response body, if anythrowable - the underlying cause of the failurepublic abstract void onFailure(int statusCode,
Header[] headers,
java.lang.Throwable throwable,
java.io.File file)
statusCode - http file status lineheaders - file http headers if anythrowable - returned throwablefile - file in which the file is storedpublic final void onSuccess(int statusCode,
Header[] headers,
byte[] responseBytes)
AsyncHttpResponseHandleronSuccess 在类中 AsyncHttpResponseHandlerstatusCode - the status code of the responseheaders - return headers, if anyresponseBytes - the body of the HTTP response from the serverpublic abstract void onSuccess(int statusCode,
Header[] headers,
java.io.File file)
statusCode - http response status lineheaders - response http headers if anyfile - file in which the response is storedprotected byte[] getResponseData(HttpEntity entity)
throws java.io.IOException
AsyncHttpResponseHandlerentity - can be nulljava.io.IOException - if reading entity or creating byte array failed