當前位置: 首頁>>代碼示例>>Java>>正文


Java RetryPolicy類代碼示例

本文整理匯總了Java中com.android.volley.RetryPolicy的典型用法代碼示例。如果您正苦於以下問題:Java RetryPolicy類的具體用法?Java RetryPolicy怎麽用?Java RetryPolicy使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RetryPolicy類屬於com.android.volley包,在下文中一共展示了RetryPolicy類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 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.
 */
protected 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));

    //reentry the requestQueue
    RequestQueue requestQueue = getRequestQueue(request);
    if (requestQueue != null) {
        requestQueue.add(request);
    }

    throw new RetryError();
}
 
開發者ID:HujiangTechnology,項目名稱:RestVolley,代碼行數:26,代碼來源:RVNetwork.java

示例2: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:cowthan,項目名稱:AyoSunny,代碼行數:24,代碼來源:BasicNetwork.java

示例3: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
private static void attemptRetryOnException(String paramString, Request<?> paramRequest, VolleyError paramVolleyError)
  throws VolleyError
{
  RetryPolicy localRetryPolicy = paramRequest.mRetryPolicy;
  int i = paramRequest.getTimeoutMs();
  try
  {
    localRetryPolicy.retry(paramVolleyError);
    Object[] arrayOfObject2 = new Object[2];
    arrayOfObject2[0] = paramString;
    arrayOfObject2[1] = Integer.valueOf(i);
    paramRequest.addMarker(String.format("%s-retry [timeout=%s]", arrayOfObject2));
    return;
  }
  catch (VolleyError localVolleyError)
  {
    Object[] arrayOfObject1 = new Object[2];
    arrayOfObject1[0] = paramString;
    arrayOfObject1[1] = Integer.valueOf(i);
    paramRequest.addMarker(String.format("%s-timeout-giveup [timeout=%s]", arrayOfObject1));
    throw localVolleyError;
  }
}
 
開發者ID:ChiangC,項目名稱:FMTech,代碼行數:24,代碼來源:BasicNetwork.java

示例4: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:himanshuagarwal77225,項目名稱:BookMySkills,代碼行數:26,代碼來源:BasicNetwork.java

示例5: ProjectileRequest

import com.android.volley.RetryPolicy; //導入依賴的package包/類
public ProjectileRequest(int method, String url, Map<String, String> headers, Map<String, String> params, final ResponseListener<T> responseListener, Priority p, RetryPolicy retryPolicy, Object tag, boolean shouldCache) {
    super(method, url, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError volleyError) {
            if(responseListener != null) responseListener.onError(volleyError);
        }
    });

    mListener = responseListener;
    mHeaders = headers;
    mParams = params;
    mPriority = p;
    setRetryPolicy(retryPolicy);
    setTag(tag);
    setShouldCache(shouldCache);
}
 
開發者ID:yayuhh,項目名稱:Projectile,代碼行數:17,代碼來源:ProjectileRequest.java

示例6: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
     * 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 = retryPolicy.getCurrentTimeout();

        try {
            retryPolicy.retry(exception);
        } catch (VolleyError e) {
//            request.addMarker(
//                    String.format("%s-timeout-giveup [timeout=%s]", logPrefix, oldTimeout));
            Log.d("network", String.format("%s-timeout-giveup [timeout=%s]", logPrefix, oldTimeout));
            throw e;
        }
        Log.d("network", String.format("%s-retry [timeout=%s]", logPrefix, oldTimeout));
        //request.addMarker(String.format("%s-retry [timeout=%s]", logPrefix, oldTimeout));
    }
 
開發者ID:hunatika615,項目名稱:egg-android,代碼行數:23,代碼來源:OkHttpNetwork.java

示例7: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:20,代碼來源:BasicNetwork.java

示例8: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
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 var6) {
        request.addMarker(String.format("%s-timeout-giveup [timeout=%s]", logPrefix, oldTimeout));
        throw var6;
    }

    request.addMarker(String.format("%s-retry [timeout=%s]", logPrefix, oldTimeout));
}
 
開發者ID:octaware,項目名稱:super-volley,代碼行數:14,代碼來源:BasicNetwork.java

示例9: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:HanyeeWang,項目名稱:GeekZone,代碼行數:20,代碼來源:BaseNetwork.java

示例10: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
private static void attemptRetryOnException(String logPrefix, Request<?> request, VolleyError exception) throws VolleyError {
    RetryPolicy retryPolicy = request.getRetryPolicy();
    int oldTimeout = request.getTimeoutMs();
    try {
        retryPolicy.retry(exception);
        request.addMarker(String.format("%s-retry [timeout=%s]", new Object[]{logPrefix, Integer.valueOf(oldTimeout)}));
    } catch (VolleyError e) {
        request.addMarker(String.format("%s-timeout-giveup [timeout=%s]", new Object[]{logPrefix, Integer.valueOf(oldTimeout)}));
        throw e;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:12,代碼來源:BasicNetwork.java

示例11: generateRetryPolicy

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * Generate a default retry policy (30 seconds for the timeout, 1 retry maximum, 1 backoff multiplier)
 * @return a default retry policy, not null
 */
@NonNull
private static RetryPolicy generateRetryPolicy() {
    return new DefaultRetryPolicy(requestTimeout,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
開發者ID:neopixl,項目名稱:Spitfire,代碼行數:11,代碼來源:SpitfireManager.java

示例12: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 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));
}
 
開發者ID:nordfalk,項目名稱:EsperantoRadio,代碼行數:20,代碼來源:DrBasicNetwork.java

示例13: makeRequest

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 如果傳入的tag有效,則可以通過該tag取消請求的發送
 *
 * @param request    req
 * @param requestTag tag
 */
private void makeRequest(VolleyRequest request, String requestTag) {
    if (!TextUtils.isEmpty(requestTag)) {
        request.setTag(requestTag);
    }
    // step4:放入請求隊列
    RequestQueue requestQueue = VolleyManager.getInstance(mContext).getRequestQueue();
    int socketTimeout = 5000;//30 seconds - change to what you want
    RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
    request.setRetryPolicy(policy);
    requestQueue.add(request);
}
 
開發者ID:jessie345,項目名稱:RealArchitecture,代碼行數:18,代碼來源:VolleyClient.java

示例14: setRetryPolicy

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * set the retry policy, default is {@link DefaultRetryPolicy()}.
 * @param retryPolicy see {@link DefaultRetryPolicy}
 * @return {@link RestVolleyRequest}
 * @see Request#setRetryPolicy(RetryPolicy)
 */
public R setRetryPolicy(RetryPolicy retryPolicy) {
    if (mRetryPolicy != null) {
        mRetryPolicy = retryPolicy;
    }
    return (R)this;
}
 
開發者ID:HujiangTechnology,項目名稱:RestVolley,代碼行數:13,代碼來源:RestVolleyRequest.java

示例15: attemptRetryOnException

import com.android.volley.RetryPolicy; //導入依賴的package包/類
/**
 * 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 {
    // 拿到 該請求 Request 內對應的 重試策略 類
    RetryPolicy retryPolicy = request.getRetryPolicy();
    // 獲取請求此次的超時時間
    int oldTimeout = request.getTimeoutMs();

    try {
        /*
         * 進行 重試:
         * 根據 請求此次的超時時間 * 退避乘數 = 此次的實際超時時間
         * 將 實際超時時間 累加到 重試策略類 中的 超時總時長 內
         */
        retryPolicy.retry(exception);
    } catch (VolleyError e) {
        // 打印 log
        request.addMarker(
                String.format("%s-timeout-giveup [timeout=%s]", logPrefix, oldTimeout));
        throw e;
    }
    // 打印 log
    request.addMarker(String.format("%s-retry [timeout=%s]", logPrefix, oldTimeout));
}
 
開發者ID:CaMnter,項目名稱:SaveVolley,代碼行數:33,代碼來源:BasicNetwork.java


注:本文中的com.android.volley.RetryPolicy類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。