コード例 #1
0
ファイル: BasicNetwork.java プロジェクト: Guruev/DatingApp
 /** Logs requests that took over SLOW_REQUEST_THRESHOLD_MS to complete. */
 private void logSlowRequests(
     long requestLifetime, Request<?> request, byte[] responseContents, StatusLine statusLine) {
   if (DEBUG || requestLifetime > SLOW_REQUEST_THRESHOLD_MS) {
     VolleyLog.d(
         "HTTP response for request=<%s> [lifetime=%d], [size=%s], " + "[rc=%d], [retryCount=%s]",
         request,
         requestLifetime,
         responseContents != null ? responseContents.length : "null",
         statusLine.getStatusCode(),
         request.getRetryPolicy().getCurrentRetryCount());
   }
 }
コード例 #2
0
ファイル: BasicNetwork.java プロジェクト: Guruev/DatingApp
  /**
   * Attempts to prepare the request for a retry. If there are no more attempts remaining in the
   * request's retry policy, a timeout exception is thrown.
   *
   * @param request The request to use.
   */
  private static void attemptRetryOnException(
      String logPrefix, Request<?> request, VolleyError exception) throws VolleyError {
    RetryPolicy retryPolicy = request.getRetryPolicy();
    int oldTimeout = request.getTimeoutMs();

    try {
      retryPolicy.retry(exception);
    } catch (VolleyError e) {
      request.addMarker(String.format("%s-timeout-giveup [timeout=%s]", logPrefix, oldTimeout));
      throw e;
    }
    request.addMarker(String.format("%s-retry [timeout=%s]", logPrefix, oldTimeout));
  }