当前位置: 首页>>代码示例>>Java>>正文


Java Request.setRetryPolicy方法代码示例

本文整理汇总了Java中com.android.volley.Request.setRetryPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java Request.setRetryPolicy方法的具体用法?Java Request.setRetryPolicy怎么用?Java Request.setRetryPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.volley.Request的用法示例。


在下文中一共展示了Request.setRetryPolicy方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: placeJsonArrayRequest

import com.android.volley.Request; //导入方法依赖的package包/类
/**
 * @param apiTag         tag to uniquely distinguish Volley requests. Null is allowed
 * @param url            URL to fetch the string at
 * @param httpMethod     the request method to use (GET or POST)
 * @param params         A {@link JSONArray} to post with the request. Null is allowed and
 *                       indicates no parameters will be posted along with request.
 * @param headers        optional Http headers
 * @param serverCallback Listener to receive the String response
 */
public void placeJsonArrayRequest(@Nullable final String apiTag, String url, int httpMethod, @Nullable JSONArray params, final @Nullable HashMap<String, String> headers, final ServerCallback serverCallback) {

    Request request = new JsonArrayRequest(httpMethod, url, params, new Response.Listener<JSONArray>() {
        @Override
        public void onResponse(JSONArray response) {
            serverCallback.onAPIResponse(apiTag, response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            serverCallback.onErrorResponse(apiTag, error);
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            return headers != null ? headers : super.getHeaders();
        }
    };

    request.setRetryPolicy(retryPolicy);

    addToRequestQueue(request);
}
 
开发者ID:ferozbaig96,项目名称:VolleySimple,代码行数:33,代码来源:VolleySimple.java

示例2: postRequest

import com.android.volley.Request; //导入方法依赖的package包/类
public void postRequest(Request<?> request){
    request.setRetryPolicy(new DefaultRetryPolicy(10000,
            DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    mQueue.add(request);

}
 
开发者ID:qq545057627,项目名称:JInOne,代码行数:8,代码来源:NetManager.java

示例3: placeJsonObjectRequest

import com.android.volley.Request; //导入方法依赖的package包/类
/**
 * @param apiTag         tag to uniquely distinguish Volley requests. Null is allowed
 * @param url            URL to fetch the string at
 * @param httpMethod     the request method to use (GET or POST)
 * @param params         A {@link JSONObject} to post with the request. Null is allowed and
 *                       indicates no parameters will be posted along with request.
 * @param headers        optional Http headers
 * @param serverCallback Listener to receive the String response
 */
public void placeJsonObjectRequest(@Nullable final String apiTag, String url, int httpMethod, @Nullable JSONObject params, final @Nullable HashMap<String, String> headers, final ServerCallback serverCallback) {

    Request request = new JsonObjectRequest(httpMethod, url, params, new Response.Listener<JSONObject>() {
        @Override
        public void onResponse(JSONObject response) {
            serverCallback.onAPIResponse(apiTag, response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            serverCallback.onErrorResponse(apiTag, error);
        }
    }) {
        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            return headers != null ? headers : super.getHeaders();
        }
    };

    request.setRetryPolicy(retryPolicy);

    addToRequestQueue(request);
}
 
开发者ID:ferozbaig96,项目名称:VolleySimple,代码行数:33,代码来源:VolleySimple.java

示例4: addToRequestQueue

import com.android.volley.Request; //导入方法依赖的package包/类
public <T> void addToRequestQueue(Request<T> req, Context context) {
    req.setTag(TAG);
    req.setRetryPolicy(new DefaultRetryPolicy(
            MY_SOCKET_TIMEOUT_MS,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES,
            DefaultRetryPolicy.DEFAULT_BACKOFF_MULT));
    getRequestQueue(context).add(req);
}
 
开发者ID:JonathandelaSen,项目名称:TheMovies,代码行数:9,代码来源:VolleyHelper.java

示例5: addRequest

import com.android.volley.Request; //导入方法依赖的package包/类
public static void addRequest(Request<?> request, Object tag) {
    Helper.showLog("Volley/URL", request.getCacheKey());
    if (tag != null) {
        request.setTag(tag);
    }
    request.setRetryPolicy(new DefaultRetryPolicy(15000, 0, 1.0f));
    mRequestQueue.add(request);
    if (request != null && (request instanceof BaseJsonRequest)) {
        cacheIp((BaseJsonRequest) request);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:12,代码来源:RequestManager.java

示例6: placeStringRequest

import com.android.volley.Request; //导入方法依赖的package包/类
/**
 * @param apiTag         tag to uniquely distinguish Volley requests. Null is allowed
 * @param url            URL to fetch the string at
 * @param httpMethod     the request method to use (GET or POST)
 * @param params         A HashMap<String,String> to post with the request. Null is allowed and
 *                       indicates no parameters will be posted along with request.
 * @param headers        optional Http headers
 * @param serverCallback Listener to receive the String response
 */
public void placeStringRequest(@Nullable final String apiTag, String url, int httpMethod, @Nullable final HashMap<String, String> params, final HashMap<String, String> headers, final ServerCallback serverCallback) {

    Request request = new StringRequest(httpMethod, url, new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            serverCallback.onAPIResponse(apiTag, response);
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            serverCallback.onErrorResponse(apiTag, error);
        }
    }) {
        @Override
        protected Map<String, String> getParams() throws AuthFailureError {
            return params != null ? params : super.getParams();
        }

        @Override
        public Map<String, String> getHeaders() throws AuthFailureError {
            return headers != null ? headers : super.getHeaders();
        }
    };

    request.setRetryPolicy(retryPolicy);

    addToRequestQueue(request);
}
 
开发者ID:ferozbaig96,项目名称:VolleySimple,代码行数:38,代码来源:VolleySimple.java


注:本文中的com.android.volley.Request.setRetryPolicy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。