com.android.volley.RetryPolicy Java Examples
The following examples show how to use
com.android.volley.RetryPolicy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RVNetwork.java From RestVolley with Apache License 2.0 | 6 votes |
/** * 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(); }
Example #2
Source File: BasicNetwork.java From TitanjumNote with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #3
Source File: BasicNetwork.java From CrossBow with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #4
Source File: BasicNetwork.java From WayHoo with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #5
Source File: BasicNetwork.java From android_tv_metro with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #6
Source File: BasicNetwork.java From FeedListViewDemo with MIT License | 5 votes |
/** * 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)); }
Example #7
Source File: BasicNetwork.java From okulus with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #8
Source File: BasicNetwork.java From jus with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #9
Source File: BasicNetwork.java From volley with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #10
Source File: OkNetwork.java From OkVolley with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #11
Source File: BasicNetwork.java From volley_demo with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #12
Source File: BasicNetwork.java From product-emm with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #13
Source File: BasicNetwork.java From product-emm with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #14
Source File: BasicNetwork.java From android-discourse with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #15
Source File: BasicNetwork.java From volley with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #16
Source File: BasicNetwork.java From android-common-utils with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #17
Source File: BasicNetwork.java From SimplifyReader with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #18
Source File: BasicNetwork.java From android-project-wo2b with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #19
Source File: RequestTest.java From SaveVolley with Apache License 2.0 | 5 votes |
@Test public void publicMethods() throws Exception { // Catch-all test to find API-breaking changes. assertNotNull(Request.class.getConstructor(int.class, String.class, Response.ErrorListener.class)); assertNotNull(Request.class.getMethod("getMethod")); assertNotNull(Request.class.getMethod("setTag", Object.class)); assertNotNull(Request.class.getMethod("getTag")); assertNotNull(Request.class.getMethod("getErrorListener")); assertNotNull(Request.class.getMethod("getTrafficStatsTag")); assertNotNull(Request.class.getMethod("setRetryPolicy", RetryPolicy.class)); assertNotNull(Request.class.getMethod("addMarker", String.class)); assertNotNull(Request.class.getDeclaredMethod("finish", String.class)); assertNotNull(Request.class.getMethod("setRequestQueue", RequestQueue.class)); assertNotNull(Request.class.getMethod("setSequence", int.class)); assertNotNull(Request.class.getMethod("getSequence")); assertNotNull(Request.class.getMethod("getUrl")); assertNotNull(Request.class.getMethod("getCacheKey")); assertNotNull(Request.class.getMethod("setCacheEntry", Cache.Entry.class)); assertNotNull(Request.class.getMethod("getCacheEntry")); assertNotNull(Request.class.getMethod("cancel")); assertNotNull(Request.class.getMethod("isCanceled")); assertNotNull(Request.class.getMethod("getHeaders")); assertNotNull(Request.class.getDeclaredMethod("getParams")); assertNotNull(Request.class.getDeclaredMethod("getParamsEncoding")); assertNotNull(Request.class.getMethod("getBodyContentType")); assertNotNull(Request.class.getMethod("getBody")); assertNotNull(Request.class.getMethod("setShouldCache", boolean.class)); assertNotNull(Request.class.getMethod("shouldCache")); assertNotNull(Request.class.getMethod("getPriority")); assertNotNull(Request.class.getMethod("getTimeoutMs")); assertNotNull(Request.class.getMethod("getRetryPolicy")); assertNotNull(Request.class.getMethod("markDelivered")); assertNotNull(Request.class.getMethod("hasHadResponseDelivered")); assertNotNull( Request.class.getDeclaredMethod("parseNetworkResponse", NetworkResponse.class)); assertNotNull(Request.class.getDeclaredMethod("parseNetworkError", VolleyError.class)); assertNotNull(Request.class.getDeclaredMethod("deliverResponse", Object.class)); assertNotNull(Request.class.getMethod("deliverError", VolleyError.class)); }
Example #20
Source File: BasicNetwork.java From SaveVolley with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #21
Source File: BasicNetwork.java From device-database with Apache License 2.0 | 5 votes |
/** * 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)); }
Example #22
Source File: RestVolleyRequest.java From RestVolley with Apache License 2.0 | 5 votes |
/** * 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; }
Example #23
Source File: RetryPolicyFactory.java From hex with Apache License 2.0 | 4 votes |
public static RetryPolicy build() { return new DefaultRetryPolicy(SOCKET_TIMEOUT_MS, MAX_RETRIES, BACKOFF_MULTIPLIER); }
Example #24
Source File: OkRequest.java From OkVolley with Apache License 2.0 | 4 votes |
@Override public Request<?> setRetryPolicy(RetryPolicy retryPolicy) { return super.setRetryPolicy(retryPolicy); }
Example #25
Source File: OkRequest.java From OkVolley with Apache License 2.0 | 4 votes |
@Override public RetryPolicy getRetryPolicy() { return super.getRetryPolicy(); }
Example #26
Source File: HttpJsonObjectRequest.java From UPMiss with GNU General Public License v3.0 | 4 votes |
@Override public RetryPolicy getRetryPolicy() { return mRetryPolicy; }
Example #27
Source File: HttpJsonArrayRequest.java From UPMiss with GNU General Public License v3.0 | 4 votes |
@Override public RetryPolicy getRetryPolicy() { return mRetryPolicy; }
Example #28
Source File: BaseNetwork.java From Airbnb-Android-Google-Map-View with MIT License | 4 votes |
/** * For Post Method with parameters in the content body * * @param methodType Type of network call eg, GET,POST, etc. * @param url The url to hit * @param paramsObject JsonObject for POST request, null for GET request * @param requestType Type of Network request */ public void getJSONObjectForRequest(int methodType, String url, JSONObject paramsObject, final int requestType) { if (NetworkUtil.isInternetConnected(mContext)) { JsonObjectRequest jsObjRequest = new JsonObjectRequest (methodType, url, paramsObject, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { try { handleResponse(response, requestType); } catch (JSONException e) { e.printStackTrace(); } } }, new ErrorListener() { @Override public void onErrorResponse(VolleyError error) { handleError(error); } }) { @Override public String getBodyContentType() { return "application/x-www-form-urlencoded; charset=UTF-8"; } @Override public Map<String, String> getHeaders() throws AuthFailureError { return getRequestHeaderForAuthorization(); } @Override protected Map<String, String> getParams() throws AuthFailureError { Map<String, String> params = new HashMap<String, String>(); return params; } }; int socketTimeout = 5000;//30 seconds - change to what you want RetryPolicy policy = new DefaultRetryPolicy(socketTimeout, 2, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); jsObjRequest.setRetryPolicy(policy); CustomVolleyRequestQueue.getInstance(mContext).getRequestQueue().add(jsObjRequest); } }
Example #29
Source File: RequestTest.java From volley with Apache License 2.0 | 4 votes |
@Test public void publicMethods() throws Exception { // Catch-all test to find API-breaking changes. assertNotNull( Request.class.getConstructor( int.class, String.class, Response.ErrorListener.class)); assertNotNull(Request.class.getMethod("getMethod")); assertNotNull(Request.class.getMethod("setTag", Object.class)); assertNotNull(Request.class.getMethod("getTag")); assertNotNull(Request.class.getMethod("getErrorListener")); assertNotNull(Request.class.getMethod("getTrafficStatsTag")); assertNotNull(Request.class.getMethod("setRetryPolicy", RetryPolicy.class)); assertNotNull(Request.class.getMethod("addMarker", String.class)); assertNotNull(Request.class.getDeclaredMethod("finish", String.class)); assertNotNull(Request.class.getMethod("setRequestQueue", RequestQueue.class)); assertNotNull(Request.class.getMethod("setSequence", int.class)); assertNotNull(Request.class.getMethod("getSequence")); assertNotNull(Request.class.getMethod("getUrl")); assertNotNull(Request.class.getMethod("getCacheKey")); assertNotNull(Request.class.getMethod("setCacheEntry", Cache.Entry.class)); assertNotNull(Request.class.getMethod("getCacheEntry")); assertNotNull(Request.class.getMethod("cancel")); assertNotNull(Request.class.getMethod("isCanceled")); assertNotNull(Request.class.getMethod("getHeaders")); assertNotNull(Request.class.getDeclaredMethod("getParams")); assertNotNull(Request.class.getDeclaredMethod("getParamsEncoding")); assertNotNull(Request.class.getMethod("getBodyContentType")); assertNotNull(Request.class.getMethod("getBody")); assertNotNull(Request.class.getMethod("setShouldCache", boolean.class)); assertNotNull(Request.class.getMethod("shouldCache")); assertNotNull(Request.class.getMethod("getPriority")); assertNotNull(Request.class.getMethod("getTimeoutMs")); assertNotNull(Request.class.getMethod("getRetryPolicy")); assertNotNull(Request.class.getMethod("markDelivered")); assertNotNull(Request.class.getMethod("hasHadResponseDelivered")); assertNotNull( Request.class.getDeclaredMethod("parseNetworkResponse", NetworkResponse.class)); assertNotNull(Request.class.getDeclaredMethod("parseNetworkError", VolleyError.class)); assertNotNull(Request.class.getDeclaredMethod("deliverResponse", Object.class)); assertNotNull(Request.class.getMethod("deliverError", VolleyError.class)); }
Example #30
Source File: RestVolleyRequest.java From RestVolley with Apache License 2.0 | 2 votes |
/** * get {@link RetryPolicy}. * @return {@link RetryPolicy} * @see Request#getRetryPolicy() */ public RetryPolicy getRetryPolicy() { return mVolleyRequest == null ? mRetryPolicy : mVolleyRequest.getRetryPolicy(); }