com.android.volley.Request.getRetryPolicy()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(11.6k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中com.android.volley.Request.getRetryPolicy方法的一些代码示例,展示了Request.getRetryPolicy的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getRetryPolicy方法的具体详情如下:
包路径:com.android.volley.Request
类名称:Request
方法名:getRetryPolicy

Request.getRetryPolicy介绍

[英]Returns the retry policy that should be used for this request.
[中]返回应用于此请求的重试策略。

代码示例

代码示例来源:origin: mcxiaoke/android-volley

/**
 * 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());
  }
}

代码示例来源:origin: chentao0707/SimplifyReader

/**
 * 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());
  }
}

代码示例来源:origin: jiangqqlmj/FastDev4Android

/**
 * 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());
  }
}

代码示例来源:origin: chentao0707/SimplifyReader

/**
 * 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));
}

代码示例来源:origin: mcxiaoke/android-volley

/**
 * 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));
}

代码示例来源:origin: jiangqqlmj/FastDev4Android

/**
 * 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));
}

代码示例来源:origin: googolmo/OkVolley

@Override
public RetryPolicy getRetryPolicy() {
  return super.getRetryPolicy();
}

代码示例来源:origin: com.mcxiaoke.volley/library

/**
 * 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());
  }
}

代码示例来源:origin: cat9/EasyVolley

/**
 * 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());
  }
}

代码示例来源:origin: tazimete/android-app-food-delivery-system

/**
 * 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());
  }
}

代码示例来源:origin: MewX/light-novel-library_Wenku8_Android

/**
 * 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());
  }
}

代码示例来源:origin: chuyangliu/tastysnake

/**
 * 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());
  }
}

代码示例来源:origin: xuningjack/AndroidNet

/**
 * 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());
  }
}

代码示例来源:origin: tazimete/android-app-food-delivery-system

/**
 * 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());
  }
}

代码示例来源:origin: AnandChowdhary/saga-android

/**
 * 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());
  }
}

代码示例来源:origin: jungletian/TitanjumNote

/**
 * 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());
  }
}

代码示例来源:origin: MewX/light-novel-library_Wenku8_Android

/**
 * 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));
}

代码示例来源:origin: tazimete/android-app-food-delivery-system

/**
 * 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));
}

代码示例来源:origin: googolmo/OkVolley

/**
 * Logs requests that took over SLOW_REQUEST_THRESHOLD_MS to complete.
 */
private void logSlowRequests(long requestLifetime, Request<?> request,
               byte[] responseContents, Response response) {
  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",
        response.code(), request.getRetryPolicy()
            .getCurrentRetryCount()
    );
  }
}

代码示例来源:origin: panxw/android-volley-manager

/**
 * Logs requests that took over SLOW_REQUEST_THRESHOLD_MS to complete.
 */
private void logSlowRequests(long requestLifetime, Request<?> request,
    byte[] responseContents, HttpResponse httpResponse) {
  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", httpResponse.getResponseCode(),
            request.getRetryPolicy().getCurrentRetryCount());
  }
}

相关文章