类 OkHttpPendingResult<T,​R extends ApiResponse<T>>

java.lang.Object
ai.nextbillion.maps.internal.OkHttpPendingResult<T,​R>
所有已实现的接口:
PendingResult<T>, okhttp3.Callback

public class OkHttpPendingResult<T,​R extends ApiResponse<T>>
extends java.lang.Object
implements PendingResult<T>, okhttp3.Callback
A PendingResult backed by a HTTP call executed by OkHttp, a deserialization step using Gson, rate limiting and a retry policy.

T is the type of the result of this pending result, and R is the type of the request.

  • 嵌套类概要

    从接口继承的嵌套类/接口 ai.nextbillion.maps.PendingResult

    PendingResult.Callback<T>
  • 构造器概要

    构造器 
    构造器 说明
    OkHttpPendingResult​(okhttp3.Request request, okhttp3.OkHttpClient client, java.lang.Class<R> responseClass, com.google.gson.FieldNamingPolicy fieldNamingPolicy, long errorTimeOut, java.lang.Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry, RequestMetrics metrics)  
  • 方法概要

    修饰符和类型 方法 说明
    T await()
    Performs the request synchronously.
    T awaitIgnoreError()
    Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.
    void cancel()
    Attempts to cancel the request.
    void onFailure​(okhttp3.Call call, java.io.IOException ioe)  
    void onResponse​(okhttp3.Call call, okhttp3.Response response)  
    void setCallback​(PendingResult.Callback<T> callback)
    Performs the request asynchronously, calling onResult or onFailure after the request has been completed.

    从类继承的方法 java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 构造器详细资料

    • OkHttpPendingResult

      public OkHttpPendingResult​(okhttp3.Request request, okhttp3.OkHttpClient client, java.lang.Class<R> responseClass, com.google.gson.FieldNamingPolicy fieldNamingPolicy, long errorTimeOut, java.lang.Integer maxRetries, ExceptionsAllowedToRetry exceptionsAllowedToRetry, RequestMetrics metrics)
      参数:
      request - HTTP request to execute.
      client - The client used to execute the request.
      responseClass - Model class to unmarshal JSON body content.
      fieldNamingPolicy - FieldNamingPolicy for unmarshaling JSON.
      errorTimeOut - Number of milliseconds to re-send erroring requests.
      maxRetries - Number of times allowed to re-send erroring requests.
      exceptionsAllowedToRetry - The exceptions to retry.
      metrics - metrics
  • 方法详细资料

    • setCallback

      public void setCallback​(PendingResult.Callback<T> callback)
      从接口复制的说明: PendingResult
      Performs the request asynchronously, calling onResult or onFailure after the request has been completed.
      指定者:
      setCallback 在接口中 PendingResult<T>
      参数:
      callback - The callback to call on completion.
    • await

      public T await() throws ApiException, java.io.IOException, java.lang.InterruptedException
      从接口复制的说明: PendingResult
      Performs the request synchronously.
      指定者:
      await 在接口中 PendingResult<T>
      返回:
      The result.
      抛出:
      ApiException - Thrown if the API Returned result is an error.
      java.io.IOException - Thrown when an I/O exception of some sort has occurred.
      java.lang.InterruptedException - Thrown when a thread is waiting, sleeping, or otherwise occupied, and the thread is interrupted.
    • awaitIgnoreError

      public T awaitIgnoreError()
      从接口复制的说明: PendingResult
      Performs the request synchronously, ignoring exceptions while performing the request and errors returned by the server.
      指定者:
      awaitIgnoreError 在接口中 PendingResult<T>
      返回:
      The result, or null if there was any error or exception ignored.
    • cancel

      public void cancel()
      从接口复制的说明: PendingResult
      Attempts to cancel the request.
      指定者:
      cancel 在接口中 PendingResult<T>
    • onFailure

      public void onFailure​(okhttp3.Call call, java.io.IOException ioe)
      指定者:
      onFailure 在接口中 okhttp3.Callback
    • onResponse

      public void onResponse​(okhttp3.Call call, okhttp3.Response response) throws java.io.IOException
      指定者:
      onResponse 在接口中 okhttp3.Callback
      抛出:
      java.io.IOException