Java Code Examples for com.android.volley.DefaultRetryPolicy#DEFAULT_BACKOFF_MULT

The following examples show how to use com.android.volley.DefaultRetryPolicy#DEFAULT_BACKOFF_MULT . 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: NetworkService.java    From CoolClock with GNU General Public License v3.0 5 votes vote down vote up
private void setRequestTimeout(int ms) {
    int timeout = (ms == 0) ? DefaultRetryPolicy.DEFAULT_TIMEOUT_MS : ms;

    mRetryPolicy = new DefaultRetryPolicy(timeout,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}
 
Example 2
Source File: MultiPartRequest.java    From barterli_android with Apache License 2.0 5 votes vote down vote up
public MultiPartRequest(int method, String url, Listener<T> listener, ErrorListener errorlistener) {

        super(method, url, errorlistener, new DefaultRetryPolicy(TIMEOUT_MS, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
        mListener = listener;
        mMultipartParams = new HashMap<String, MultiPartRequest.MultiPartParam>();
        mFileUploads = new HashMap<String, String>();
        
    }
 
Example 3
Source File: BaseNetwork.java    From Airbnb-Android-Google-Map-View with MIT License 4 votes vote down vote up
/**
 * 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 4
Source File: NetworkHelper.java    From IceNet with Apache License 2.0 4 votes vote down vote up
public DefaultRetryPolicy retryPolicy() {
    return new DefaultRetryPolicy((int) TimeUnit.SECONDS.toMillis(20),
            0,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}