类 RequestFuture<T>
java.lang.Object
com.android.volley.toolbox.RequestFuture<T>
- 类型参数:
T- The type of parsed response this future expects.
- 所有已实现的接口:
Response.ErrorListener,Response.Listener<T>,Future<T>
public class RequestFuture<T>
extends Object
implements Future<T>, Response.Listener<T>, Response.ErrorListener
A Future that represents a Volley request.
Used by providing as your response and error listeners. For example:
RequestFuture<JSONObject> future = RequestFuture.newFuture();
MyRequest request = new MyRequest(URL, future, future);
// If you want to be able to cancel the request:
future.setRequest(requestQueue.add(request));
// Otherwise:
requestQueue.add(request);
try {
JSONObject response = future.get();
// do something with response
} catch (InterruptedException e) {
// handle the error
} catch (ExecutionException e) {
// handle the error
}
-
方法概要
修饰符和类型方法说明booleancancel(boolean mayInterruptIfRunning) get()booleanbooleanisDone()static <E> RequestFuture<E>voidonErrorResponse(VolleyError error) Callback method that an error has been occurred with the provided error code and optional user-readable message.voidonResponse(T response) Called when a response is received.voidsetRequest(Request<?> request)
-
方法详细资料
-
newFuture
-
setRequest
-
cancel
public boolean cancel(boolean mayInterruptIfRunning) -
get
- 指定者:
get在接口中Future<T>- 抛出:
InterruptedExceptionExecutionException
-
get
public T get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException - 指定者:
get在接口中Future<T>- 抛出:
InterruptedExceptionExecutionExceptionTimeoutException
-
isCancelled
public boolean isCancelled()- 指定者:
isCancelled在接口中Future<T>
-
isDone
public boolean isDone() -
onResponse
从接口复制的说明:Response.ListenerCalled when a response is received.- 指定者:
onResponse在接口中Response.Listener<T>
-
onErrorResponse
从接口复制的说明:Response.ErrorListenerCallback method that an error has been occurred with the provided error code and optional user-readable message.- 指定者:
onErrorResponse在接口中Response.ErrorListener
-