use of com.android.volley.DefaultRetryPolicy in project glide by bumptech.
the class Api method query.
public void query(Query query) {
if (lastQueryResult != null && lastQueryResult.query.equals(query)) {
for (QueryListener listener : queryListeners) {
listener.onSearchCompleted(lastQueryResult.query, lastQueryResult.results);
}
return;
}
FlickrQueryResponseListener responseListener = new FlickrQueryResponseListener(new PhotoJsonStringParser(), query, queryListeners);
StringRequest request = new StringRequest(Request.Method.GET, query.getUrl(), responseListener, responseListener);
request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 3, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
requestQueue.add(request);
}
use of com.android.volley.DefaultRetryPolicy in project WordPress-Android by wordpress-mobile.
the class RestClientUtils method getSynchronous.
/**
* Make Synchronous GET request with params
*
* @throws TimeoutException
* @throws ExecutionException
* @throws InterruptedException
*/
public JSONObject getSynchronous(String path, Map<String, String> params, RetryPolicy retryPolicy) throws InterruptedException, ExecutionException, TimeoutException {
RequestFuture<JSONObject> future = RequestFuture.newFuture();
HashMap<String, String> paramsWithLocale = getRestLocaleParams(mContext);
if (params != null) {
paramsWithLocale.putAll(params);
}
String realPath = getSanitizedPath(path);
if (TextUtils.isEmpty(realPath)) {
realPath = path;
}
paramsWithLocale.putAll(getSanitizedParameters(path));
RestRequest request = mRestClient.makeRequest(Method.GET, mRestClient.getAbsoluteURL(realPath, paramsWithLocale), null, future, future);
if (retryPolicy == null) {
retryPolicy = new DefaultRetryPolicy(REST_TIMEOUT_MS, REST_MAX_RETRIES_GET, REST_BACKOFF_MULT);
}
request.setRetryPolicy(retryPolicy);
AuthenticatorRequest authCheck = new AuthenticatorRequest(request, null, mRestClient, mAuthenticator);
//this insert the request into the queue. //TODO: Verify that everything is OK on REST calls without a valid token
authCheck.send();
JSONObject response = future.get();
return response;
}
use of com.android.volley.DefaultRetryPolicy in project WordPress-Android by wordpress-mobile.
the class RestClientUtils method get.
/**
* Make GET request with params
*/
public Request<JSONObject> get(String path, Map<String, String> params, RetryPolicy retryPolicy, Listener listener, ErrorListener errorListener) {
// turn params into querystring
HashMap<String, String> paramsWithLocale = getRestLocaleParams(mContext);
if (params != null) {
paramsWithLocale.putAll(params);
}
String realPath = getSanitizedPath(path);
if (TextUtils.isEmpty(realPath)) {
realPath = path;
}
paramsWithLocale.putAll(getSanitizedParameters(path));
RestRequest request = mRestClient.makeRequest(Method.GET, mRestClient.getAbsoluteURL(realPath, paramsWithLocale), null, listener, errorListener);
if (retryPolicy == null) {
retryPolicy = new DefaultRetryPolicy(REST_TIMEOUT_MS, REST_MAX_RETRIES_GET, REST_BACKOFF_MULT);
}
request.setRetryPolicy(retryPolicy);
AuthenticatorRequest authCheck = new AuthenticatorRequest(request, errorListener, mRestClient, mAuthenticator);
authCheck.send();
return request;
}
use of com.android.volley.DefaultRetryPolicy in project buglife-android by Buglife.
the class NetworkManager method addToRequestQueue.
public <T> void addToRequestQueue(Request<T> request) {
// Volley's default initial timeout is way too short, so let's bump it up.
RetryPolicy retryPolicy = new DefaultRetryPolicy(INITIAL_TIMEOUT_MS, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
request.setRetryPolicy(retryPolicy);
mRequestQueue.add(request);
}
use of com.android.volley.DefaultRetryPolicy in project Logdata-Android by AndroidLogData.
the class HttpService method requestCrashData.
public void requestCrashData(String apiKey, CrashReportData report, final HttpCallback callback) {
String url = makeURL(TransferType.CRASH);
HttpOption option = httpOptionSetting(apiKey);
JSONObject jsonObject = makeCrashDataJSON(report);
JsonCustomRequest request = new JsonCustomRequest(Request.Method.POST, url, option, jsonObject, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
Log.i("Response", response.get("result").toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Log.e("VolleyError", "Crash Transfer Error");
}
});
request.setRetryPolicy(new DefaultRetryPolicy(2000, 5, 1));
addRequestQueue(request);
}
Aggregations