/** * 返回对象 带进度条 * * @param url 接口 * @param tag 上下文 * @param classOfT 类对象 * @param params post需要传的参数 * @param progressTitle 进度条文字 * @param LoadingShow true (显示进度) false (不显示进度) * @param listener 回调 */ public static <T> void post( String url, Object tag, Class<T> classOfT, RequestParams params, String progressTitle, boolean LoadingShow, RequestJsonListener<T> listener) { LoadingFragment dialog = new LoadingFragment(); if (LoadingShow) { dialog.show(((FragmentActivity) tag).getSupportFragmentManager(), "Loading"); dialog.setMsg(progressTitle); } ByteArrayRequest request = new ByteArrayRequest( Request.Method.POST, url, params, responseListener(listener, classOfT, LoadingShow, dialog), responseError(listener, LoadingShow, dialog)); request.setRetryPolicy( new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); addRequest(request, tag); }
/** * 返回String * * @param url 接口 * @param tag 上下文 * @param params post需要传的参数 * @param listener 回调 */ public static void post(String url, Object tag, RequestParams params, RequestListener listener) { ByteArrayRequest request = new ByteArrayRequest( Request.Method.POST, url, params, responseListener(listener, false, null), responseError(listener, false, null)); request.setRetryPolicy( new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); addRequest(request, tag); }
/** * 返回对象 * * @param url 连接 * @param tag 上下文 * @param classOfT 类对象 * @param listener 回调 */ public static <T> void get( String url, Object tag, Class<T> classOfT, RequestJsonListener<T> listener) { ByteArrayRequest request = new ByteArrayRequest( Request.Method.GET, url, null, responseListener(listener, classOfT, false, null), responseError(listener, false, null)); request.setRetryPolicy( new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); addRequest(request, tag); }
/** * 返回String 带进度条 * * @param url 连接 * @param tag 上下文 * @param progressTitle 进度条文字 * @param listener 回调 */ public static void get(String url, Object tag, String progressTitle, RequestListener listener) { LoadingFragment dialog = new LoadingFragment(); dialog.show(((FragmentActivity) tag).getSupportFragmentManager(), "Loading"); dialog.setMsg(progressTitle); ByteArrayRequest request = new ByteArrayRequest( Request.Method.GET, url, null, responseListener(listener, true, dialog), responseError(listener, true, dialog)); // 设置超时时间重连次数 request.setRetryPolicy( new DefaultRetryPolicy( 5000, DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT)); addRequest(request, tag); }