public void check(final Callback callback) { mCallback = callback; StringRequest request = new StringRequest(Request.Method.GET, UPDATE_URL, this, this); request.setRetryPolicy(new DefaultRetryPolicy(mTimeOut, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); request.setTag("update-check"); request.setShouldCache(false); mRequestQueue.add(request); }
public void load(String url, final OnStringListener listener) { StringRequest request = new StringRequest(url, new Response.Listener<String>() { @Override public void onResponse(String s) { listener.onSuccess(s); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { listener.onError(volleyError); } }); request.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); VolleySingleton.getVolleySingleton(context).addToRequestQueue(request); }
private void loadSearchSuggestions(final String query) { String showName = query.replaceAll("\\s", "+"); RequestQueue requestQueue = VolleySingleton.getInstance().getRequestQueue(); JsonArrayRequest req = new JsonArrayRequest( API.TV_MAZE_SEARCH + showName, new Response.Listener<JSONArray>() { @Override public void onResponse(JSONArray response) { List<SearchSuggestions> searchSuggestions = new ArrayList<>(); JSONObject object; try { for (int j = 0; j < response.length() && searchSuggestions.size() < 5; j++) { object = response.getJSONObject(j).getJSONObject("show"); SearchSuggestions suggestion = new SearchSuggestions(object.getString("name")); if (!searchSuggestions.contains(suggestion)) { searchSuggestions.add(suggestion); } } } catch (JSONException e) { //Log.e("JSON exception", e.getMessage()); } if (searchView.isSearchBarFocused()) { searchView.swapSuggestions(searchSuggestions); } searchView.hideProgress(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { searchView.hideProgress(); } }); req.setRetryPolicy(new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); requestQueue.add(req); }
void startTutorialShadeNotificationTest() { this.phone.animate().alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(500).setStartDelay(0).withEndAction(new Runnable() { public void run() { OOBTutorialActivity.this.shadeHeight = OOBTutorialActivity.this.shade.getHeight(); OOBTutorialActivity.this.shade.setVisibility(View.GONE); OOBTutorialActivity.this.explanation.animate().alpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(500).setStartDelay(0).withEndAction(new Runnable() { public void run() { OOBTutorialActivity.this.updateText(OOBTutorialActivity.this.explanation, R.string.oob_popout_tab_explanation_shade_notification_test, OOBTutorialActivity.READ_DELAY, new Runnable() { public void run() { OOBTutorialActivity.this.updateText(OOBTutorialActivity.this.explanation, R.string.oob_pullout_shade_explanation, OOBTutorialActivity.READ_DELAY, new Runnable() { public void run() { OOBTutorialActivity.this.enableShadePullHandler(); } }); } }); } }); } }); }
public void setUnreadCount(int unreadCount, final AnimationPNGSequence.IAnimationListener listener) { final TextView badgeCountText = (TextView) findViewById(R.id.text_badge_count); badgeCountText.setAlpha(0.0f); if (unreadCount == 0) { badgeCountText.setText("0"); getHeadAnimation().playAnimation("IDLE"); return; } String nextText = String.format("%d", new Object[]{Integer.valueOf(unreadCount)}); getHeadAnimation().playAnimation("IDLE_BACK"); badgeCountText.setText(nextText); badgeCountText.setAlpha(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); badgeCountText.setScaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); badgeCountText.setScaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT); badgeCountText.animate().scaleY(1.3f).scaleX(1.3f).setDuration(200).withEndAction(new Runnable() { public void run() { badgeCountText.animate().scaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).scaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setDuration(200).withEndAction(new Runnable() { public void run() { if (listener != null) { listener.onAnimationFinished(); } } }); } }); }
public void animateIn(int duration) { int increment; int start = 0; int end = 0; if (this.exitOnRight) { start = this.buttons.size() - 1; increment = -1; } else { end = this.buttons.size() - 1; increment = 1; } int index = start; while (true) { ((ImageButton) this.buttons.get(index)).animate().scaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).scaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setInterpolator(new ElasticOutInterpolator(1.2f, 2.0f)).setDuration((long) duration).start(); if (index == end) { this.closeLeft.animate().scaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).scaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setInterpolator(new ElasticOutInterpolator(1.2f, 2.0f)).setDuration((long) duration).start(); this.closeRight.animate().scaleX(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).scaleY(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT).setInterpolator(new ElasticOutInterpolator(1.2f, 2.0f)).setDuration((long) duration).start(); return; } index += increment; } }
public float getInterpolation(float t) { if (t == 0.0f) { return 0.0f; } if (t >= DefaultRetryPolicy.DEFAULT_BACKOFF_MULT) { return DefaultRetryPolicy.DEFAULT_BACKOFF_MULT; } float s; if (this._period == 0.0f) { this._period = 0.3f; } if (this._amplitude == 0.0f || this._amplitude < DefaultRetryPolicy.DEFAULT_BACKOFF_MULT) { this._amplitude = DefaultRetryPolicy.DEFAULT_BACKOFF_MULT; s = this._period / 4.0f; } else { s = (float) (Math.asin((double) (DefaultRetryPolicy.DEFAULT_BACKOFF_MULT / this._amplitude)) * (((double) this._period) / 6.283185307179586d)); } return (float) (((((double) this._amplitude) * Math.pow(2.0d, (double) (-10.0f * t))) * Math.sin((((double) (t - s)) * 6.283185307179586d) / ((double) this._period))) + 1.0d); }
public float getInterpolation(float t) { if (t == 0.0f) { return 0.0f; } if (t >= DefaultRetryPolicy.DEFAULT_BACKOFF_MULT) { return DefaultRetryPolicy.DEFAULT_BACKOFF_MULT; } float s; if (this._period == 0.0f) { this._period = 0.3f; } if (this._amplitude == 0.0f || this._amplitude < DefaultRetryPolicy.DEFAULT_BACKOFF_MULT) { this._amplitude = DefaultRetryPolicy.DEFAULT_BACKOFF_MULT; s = this._period / 4.0f; } else { s = (float) ((((double) this._period) / 6.283185307179586d) * Math.asin((double) (DefaultRetryPolicy.DEFAULT_BACKOFF_MULT / this._amplitude))); } t -= DefaultRetryPolicy.DEFAULT_BACKOFF_MULT; return (float) (-((Math.pow(2.0d, (double) (10.0f * t)) * ((double) this._amplitude)) * Math.sin((((double) (t - s)) * 6.283185307179586d) / ((double) this._period)))); }
public void setExpandedHeightInternal(float h) { float f = 0.0f; if (Float.isNaN(h)) { Log.v(TAG, "setExpandedHeightInternal: warning: h=NaN, using 0 instead", new Throwable()); h = 0.0f; } float fh = getFullHeight(); if (fh == 0.0f) { } if (h < 0.0f) { h = 0.0f; } if (!(this.mRubberbandingEnabled && (this.mTracking || this.mRubberbanding)) && h > fh) { h = fh; } this.mExpandedHeight = h; ((PanelHolder) getParent()).setExpandedHeight((float) getTargetExpandedHeight()); requestLayout(); if (fh != 0.0f) { f = h / fh; } this.mExpandedFraction = Math.min(DefaultRetryPolicy.DEFAULT_BACKOFF_MULT, f); }
public final void run() { d dVar = this.b; a aVar = this.a; if (aVar != null && "toast".equals(aVar.k)) { JSONObject jSONObject = aVar.m; CharSequence optString = jSONObject.optString(Utils.RESPONSE_CONTENT); int optInt = jSONObject.optInt(SportRecordDao.DURATION); int i = 1; if (optInt < DefaultRetryPolicy.DEFAULT_TIMEOUT_MS) { i = 0; } Toast.makeText(dVar.b, optString, i).show(); new Timer().schedule(new f(dVar, aVar), (long) i); } a aVar2 = a.NONE_ERROR; if (aVar2 != a.NONE_ERROR) { try { this.b.a(this.a.i, aVar2); } catch (JSONException e) { } } }
public void execute() { final String url = URL + "/remind"; StringRequest req = new StringRequest(Request.Method.POST, url, this, this) { @Override public HashMap<String, String> getHeaders() { return getDefaultHeaders(); } @Override public byte[] getBody() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("fromUsername", mUsername); params.put("toUsername", mToUsername); params.put("guid", mGuid); params.put("isRemindingRef", isRemindingRef ? "1" : "0"); return new JSONObject(params).toString().getBytes(); } }; req.setRetryPolicy(new DefaultRetryPolicy( ASYNC_CONNECTION_NORMAL_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 0)); VolleyRequestQueue.getInstance().addToRequestQueue(req); }
public void execute() { String url; try { url = URL + "/getuserinfo?username=" + URLEncoder.encode(mUsername, "utf-8"); } catch (UnsupportedEncodingException e) { url = URL + "/getuserinfo?username=" + mUsername; } StringRequest req = new StringRequest(Request.Method.GET, url, this, this) { @Override public HashMap<String, String> getHeaders() { return getDefaultHeaders(); } }; req.setRetryPolicy(new DefaultRetryPolicy( ASYNC_CONNECTION_NORMAL_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 0)); VolleyRequestQueue.getInstance().addToRequestQueue(req); }
public void execute() { final String url = URL + "/register"; isRegistering = true; StringRequest req = new StringRequest(Request.Method.POST, url, this, this) { @Override public Map<String, String> getHeaders() { return getDefaultHeaders(); } @Override public byte[] getBody() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("username", mUsername); params.put("device", "android"); params.put("pushID", mPushID); return new JSONObject(params).toString().getBytes(); } }; req.setRetryPolicy(new DefaultRetryPolicy( ASYNC_CONNECTION_EXTENDED_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 0)); VolleyRequestQueue.getInstance().addToRequestQueue(req); }
public void execute() { final String url = URL + "/updategoal"; StringRequest req = new StringRequest(Request.Method.POST, url, this, this) { @Override public HashMap<String, String> getHeaders() { return getDefaultHeaders(); } @Override public byte[] getBody() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("username", mUsername); params.put("guid", mGuid); params.put("goalCompleteResult", String.valueOf(mGoalCompleteResult.ordinal())); return new JSONObject(params).toString().getBytes(); } }; req.setRetryPolicy(new DefaultRetryPolicy( ASYNC_CONNECTION_EXTENDED_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 0)); VolleyRequestQueue.getInstance().addToRequestQueue(req); }
public void execute() { final String url = URL + "/upvote"; StringRequest req = new StringRequest(Request.Method.POST, url, this, this) { @Override public HashMap<String, String> getHeaders() { return getDefaultHeaders(); } @Override public byte[] getBody() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("username", mUsername); params.put("guid", mGuid); return new JSONObject(params).toString().getBytes(); } }; req.setRetryPolicy(new DefaultRetryPolicy( ASYNC_CONNECTION_NORMAL_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 0)); VolleyRequestQueue.getInstance().addToRequestQueue(req); }
public void execute() { final String url = URL + "/sync"; isSyncing = true; StringRequest req = new StringRequest(Request.Method.POST, url, this, this) { @Override public HashMap<String, String> getHeaders() { return getDefaultHeaders(); } @Override public byte[] getBody() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("username", mUsername); params.put("lastSyncedTime", String.valueOf(mLastSyncedTimeEpoch)); return new JSONObject(params).toString().getBytes(); } }; req.setRetryPolicy(new DefaultRetryPolicy( ASYNC_CONNECTION_EXTENDED_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 0)); VolleyRequestQueue.getInstance().addToRequestQueue(req); }
public void execute() { final String url = URL + "/updateuserinfo"; StringRequest req = new StringRequest(Request.Method.POST, url, this, this) { @Override public HashMap<String, String> getHeaders() { return getDefaultHeaders(); } @Override public byte[] getBody() throws AuthFailureError { Map<String, String> params = new HashMap<>(); params.put("bio", mBio); params.put("username", mUsername); params.put("pushID", mPushID); return new JSONObject(params).toString().getBytes(); } }; req.setRetryPolicy(new DefaultRetryPolicy( ASYNC_CONNECTION_NORMAL_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, 0)); VolleyRequestQueue.getInstance().addToRequestQueue(req); }
/** * @param url * @param jsonStr * @param _listener * @param _errorListener */ public static JsonStringRequest addJsonPostRequest(final String url, final String jsonStr, final Listener<JSONObject> _listener, final ErrorListener _errorListener) { int id = REQ_ID.getAndIncrement(); Log.d(TAG, id + "_JsonRequest: " + url + ",params:[" + jsonStr + "]"); ListenerWrap<JSONObject> listener = new ListenerWrap<JSONObject>(id, _listener); ErrorListenerWrap errListener = new ErrorListenerWrap(id, _errorListener); JsonStringRequest req = new JsonStringRequest(Method.POST, url, jsonStr, listener, errListener); req.setRetryPolicy(new DefaultRetryPolicy(20 * 1000, 1, 1.0f)); requestQueue.add(req); return req; }
/** * Creates a new request with the given method. * * @param method the request {@link Method} to use * @param url URL to fetch the Object * @param clazz the Object class to return */ private ObjectRequest(int method, String url, Class clazz) { super(method, url, null); mClazz = clazz; mHasCache = BaseApplication.getVolleyCache().get(getCacheKey()) != null; setShouldCache(false); addEntryListener(); setRetryPolicy(new DefaultRetryPolicy(DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_BACKOFF_MULT)); mSubject = new SerializedSubject<>(PublishSubject.create()); }
public static boolean checkGoogleServer(final ConnectionListener listener) { StringRequest stringRequest = new StringRequest(Request.Method.GET, "https://www.google.com/", new Response.Listener<String>() { @Override public void onResponse(String s) { Log.d("Google Response", s); listener.success(); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { Log.d("Google Error", volleyError.toString()); listener.error(Error.SERVER_ERROR); } }); stringRequest.setShouldCache(false); stringRequest.setRetryPolicy(new DefaultRetryPolicy(5000, 0, DEFAULT_BACKOFF_MULT)); VolleySingleton.getInstance().getRequestQueue().add(stringRequest); return false; }
/** * Creates a new request with the given method. * * @param method the request {@link Method} to use * @param url URL to fetch the string at * @param listener Listener to receive the String response * @param errorListener Error listener, or null to ignore errors */ public MultipartRequest(final int index, int method, String url, Map<String, MultiPartParam> params, DataResponse listener, final ErrorResponse errorListener) { super(method, url, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { errorListener.onErrorResponse(index, error); } }); this.listener = listener; this.index = index; this.params = params; setRetryPolicy(new DefaultRetryPolicy( DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_BACKOFF_MULT )); }
public CustomRequest(final int index, int method, String url, Map<String, String> params, DataResponse serverReponseListner, final ErrorResponse errorListener) { super(method, url, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { errorListener.onErrorResponse(index, error); } }); this.listener = serverReponseListner; this.params = params; this.index = index; setRetryPolicy(new DefaultRetryPolicy( DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_BACKOFF_MULT)); }
public CustomObjectRequest(final int index, int method, String url, JSONObject jsonRequest, final DataResponse serverReponseListner, final ErrorResponse errorResponse, Map<String, String> params) { super(method, url, jsonRequest, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { serverReponseListner.onResponse(index, response); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { errorResponse.onErrorResponse(index, error); } }); this.params = params; setRetryPolicy(new DefaultRetryPolicy( DEFAULT_TIMEOUT_MS, DEFAULT_MAX_RETRIES, DEFAULT_BACKOFF_MULT)); }
public static void addRequest(Request<?> request, Object tag) { if (tag != null) { request.setTag(tag); } //给每个请求重设超时、重试次数 request.setRetryPolicy(new DefaultRetryPolicy( OUT_TIME, TIMES_OF_RETRY, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); mRequestQueue.add(request); if (BuildConfig.DEBUG) { Logger.d(request.getUrl()); } }
/** * 初始化一个GsonRequest * * @param method 请求方法 * @param url 请求地址 * @param params 请求参数,可以为null * @param clazz Clazz类型,用于GSON解析json字符串封装数据 * @param requestCode 请求码 每次请求对应一个code作为改Request的唯一标识 * @param listener 监听器用来响应结果 * @return 返回一个GsonRequest对象 */ private GsonRequest<IResponse> makeGsonRequest(int method, String url, final HttpParams params, Class<? extends IResponse> clazz, int requestCode, HttpListener listener, boolean isCache) { ResponseListener responseListener = new ResponseListener(requestCode, listener); Map<String, String> paramsMap = null;//默认为null Map<String, String> headerMap = null;//默认为null if (params != null) {//如果有参数,则构建参数 if (method == Request.Method.GET) { url = url + params.toGetParams();//如果是get请求,则把参数拼在url后面 } else { paramsMap = params.getParams();//如果不是get请求,取出HttpParams中的Map参数集合。 } headerMap = params.getHeaders();//获取设置的header信息 } GsonRequest<IResponse> request = new GsonRequest<>(method, url, paramsMap, headerMap, clazz, responseListener, responseListener, isCache, mContext); request.setRetryPolicy(new DefaultRetryPolicy());//设置超时时间,重试次数,重试因子(1,1*2,2*2,4*2)等 return request; }
public void start() { if (mRequestQueueWeakReference.get() != null && getRequest() != null) { if (shouldUseCache() && isCachableHTTPMethod() && getCache() != null) { ASFCache.ASFEntry entry = getCache().get(getCacheKey()); if (entry != null) { try { getResponseListener().onResponse((T) entry.getData()); return; }catch (ClassCastException e) {} } } if (!shouldUseCache()) { getRequest().setShouldCache(false); } getRequest().setRetryPolicy(new DefaultRetryPolicy( mNetworkTimeoutTime, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); mRequestQueueWeakReference.get().add(getRequest()); mRequestQueueWeakReference.get().start(); EasyVolley.addedRequest(this); } }
private void showArticlesInSection(String cancelTag, String section_id, RequestQueue queue, final OnFetchedArraySuccessListener successListener, final ErrorListener errorListener) { // Fetch individual section String url = getApiUrl().concat("help_center/sections/").concat(section_id).concat("/articles.json"); ZendeskJsonObjectRequest request = new ZendeskJsonObjectRequest(cancelTag, url, null, new ZendeskArrayBaseListener<JSONObject>(successListener, errorListener) { @Override public void onResponse(JSONObject sectionsObject) { try { HSKBItem[] array = retrieveArticlesFromSectionArray(sectionsObject.getJSONArray("articles")); successListener.onSuccess(array); } catch (JSONException e) { e.printStackTrace(); errorListener.onErrorResponse(new VolleyError("Parse error when getting articles in section")); } } }, errorListener); request.addCredential(staff_email_address, api_token); request.setTag(cancelTag); request.setRetryPolicy(new DefaultRetryPolicy(ZendeskJsonObjectRequest.TIMEOUT_MS, ZendeskJsonObjectRequest.MAX_RETRIES, ZendeskJsonObjectRequest.BACKOFF_MULT)); queue.add(request); queue.start(); }
public static void getAttendance(final Context mContext,Response.Listener<String> successListener, Response.ErrorListener errorListener) { String mURL = "https://academics.ddn.upes.ac.in/upes/index.php?option=com_stuattendance&task='view'&Itemid=7631"; MyStringRequest requestAttendance = new MyStringRequest(Method.POST, mURL, successListener, errorListener) { public Map<String, String> getHeaders() throws com.android.volley.AuthFailureError { Map<String, String> headers = new HashMap<String, String>(); headers.put("User-Agent", mContext.getString(R.string.UserAgent)); return headers; }; }; requestAttendance.setShouldCache(true); requestAttendance.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 3, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); MyVolley.getInstance().addToRequestQueue(requestAttendance ,mContext.getClass().getName()); }
public static void getTimeTable(final Context mContext,Response.Listener<String> successListener, Response.ErrorListener errorListener) { String mURL = "https://academics.ddn.upes.ac.in/upes/index.php?option=com_course_report&Itemid=7794"; MyStringRequest requestTimeTable = new MyStringRequest(Method.POST, mURL, successListener, errorListener) { protected Map<String, String> getParams() throws com.android.volley.AuthFailureError { Map<String, String> params = new HashMap<String, String>(); String date = DateHelper.getNetworkRequestDate(DateHelper.getToDay()); params.put("fromdate", date); params.put("submit","Show Result"); return params; }; public Map<String, String> getHeaders() throws com.android.volley.AuthFailureError { Map<String, String> headers = new HashMap<String, String>(); headers.put("User-Agent", mContext.getString(R.string.UserAgent)); return headers; }; }; requestTimeTable.setShouldCache(true); requestTimeTable.setRetryPolicy(new DefaultRetryPolicy(DefaultRetryPolicy.DEFAULT_TIMEOUT_MS, 3, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); MyVolley.getInstance().addToRequestQueue(requestTimeTable ,mContext.getClass().getName()); }
/** * Logins in with new hidden data in case previous data is corrupted. */ private void LoginWithNewHiddenData() { Log.i(getClass().getName(),"Collecting hidden data..."); String mURL = mContext.getResources().getString(R.string.URL_home); MyStringRequest request = new MyStringRequest(Method.GET, mURL, getHiddenDataSuccessListener(), myErrorListener()) { public Map<String, String> getHeaders() throws com.android.volley.AuthFailureError { Map<String, String> headers = new HashMap<String, String>(); headers.put("User-Agent", mContext.getString(R.string.UserAgent)); return headers; }; }; request.setShouldCache(false); request.setPriority(Priority.HIGH); request.setRetryPolicy(new DefaultRetryPolicy(1500, 3, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); MyVolley.getInstance().addToRequestQueue(request,mContext.getClass().getName()); }
private void getHiddenData() { Log.i(getClass().getName(),"Collecting hidden data..."); String mURL = getResources().getString(R.string.URL_home); MyStringRequest request = new MyStringRequest(Method.GET, mURL, getHiddenDataSuccessListener(), myErrorListener()) { public Map<String, String> getHeaders() throws com.android.volley.AuthFailureError { Map<String, String> headers = new HashMap<String, String>(); headers.put("Accept-Charset", charset); headers.put("User-Agent", getString(R.string.UserAgent)); return headers; }; }; request.setShouldCache(false); request.setPriority(Priority.HIGH); request.setRetryPolicy(new DefaultRetryPolicy(1500, 3, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); MyVolley.getInstance().addToRequestQueue(request,myTag); }
public VolleyRequest(HttpRequest request, Response.Listener<ResponseDelegate> listener, Response.ErrorListener errorListener) { super(translateVolleyHttpMethod(request.getMethod()), request.getUri(), errorListener); mListener = listener; mHeaders = request.getHeaders(); mRequestBody = request.getRequestBody(); mContentType = request.getContentType(); // forbid retry if not GET if (request.getMethod() != HttpRequest.Methods.GET) { setRetryPolicy(new DefaultRetryPolicy( 10000, 0, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); } }
public WearDataRequest(int method, String url, String uuid, String transformerKey, int retryCount, int timeout, String cacheKey, String tag, String bodyContentType, Map<String, String> headers, byte[] body, Priority priority, ParamsBundle transformerArgs) { super(method, url, null); this.uuid = uuid; this.cacheKey = cacheKey; this.tag = tag; this.bodyContentType = bodyContentType; this.headers = headers; this.body = body; this.priority = priority; this.transformerArgs = transformerArgs; this.transformerMap.putAll(transformerMap); this.retryPolicy = new DefaultRetryPolicy(timeout, retryCount, 1f); this.transformerKey = transformerKey; setRetryPolicy(retryPolicy); }
public static void logout(final Context context, final NetworkResultListener resultListener) { BackgroundPreprocessedRequest request = new BackgroundPreprocessedRequest(Request.Method.POST, LOGOUT_URL, null, null, new Response.Listener<JSONObject>() { @Override public void onResponse(JSONObject response) { if (resultListener != null) { resultListener.onOk(); } } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { Response<JSONObject> resp = parseNetworkResponse(error.networkResponse); if (resultListener != null) { resultListener.onError(processServerError(resp.result)); } } }); request.setHeaders(getHeaders(context)); request.setRetryPolicy(new DefaultRetryPolicy(API_CONNECTION_TIMEOUT, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); VolleySingleton.getInstance(context).getRequestQueue().add(request); }
public JacksonRequest(int timeout, int method, String url, Map<String, String> params, JacksonRequestListener<T> listener) { super(method, url, null); setShouldCache(false); mListener = listener; mAcceptedStatusCodes = new ArrayList<Integer>(); mAcceptedStatusCodes.add(HttpStatus.SC_OK); mAcceptedStatusCodes.add(HttpStatus.SC_NO_CONTENT); setRetryPolicy(new DefaultRetryPolicy(timeout, 1, 1)); if (method == Method.POST || method == Method.PUT) { mParams = params; } }