Java Code Examples for com.lidroid.xutils.http.client.HttpRequest#HttpMethod

The following examples show how to use com.lidroid.xutils.http.client.HttpRequest#HttpMethod . 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: HttpUtils.java    From android-open-project-demo with Apache License 2.0 6 votes vote down vote up
public HttpHandler<File> download(HttpRequest.HttpMethod method, String url, String target,
                                  RequestParams params, boolean autoResume, boolean autoRename, RequestCallBack<File> callback) {

    if (url == null) throw new IllegalArgumentException("url may not be null");
    if (target == null) throw new IllegalArgumentException("target may not be null");

    HttpRequest request = new HttpRequest(method, url);

    HttpHandler<File> handler = new HttpHandler<File>(httpClient, httpContext, responseTextCharset, callback);

    handler.setExpiry(currentRequestExpiry);
    handler.setHttpRedirectHandler(httpRedirectHandler);

    if (params != null) {
        request.setRequestParams(params, handler);
        handler.setPriority(params.getPriority());
    }
    handler.executeOnExecutor(EXECUTOR, request, target, autoResume, autoRename);
    return handler;
}
 
Example 2
Source File: HttpUtils.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
public <T> HttpHandler<T> send(HttpRequest.HttpMethod method, String url, RequestParams params,
                               RequestCallBack<T> callBack) {
    if (url == null) throw new IllegalArgumentException("url may not be null");

    HttpRequest request = new HttpRequest(method, url);
    return sendRequest(request, params, callBack);
}
 
Example 3
Source File: NetUtil.java    From ALLGO with Apache License 2.0 4 votes vote down vote up
private void send(HttpRequest.HttpMethod arg0,RequestParams params){
	SharedPreferences sharedPref = context.getSharedPreferences("appdata",Context.MODE_PRIVATE);
	params.addHeader("Cookie","JSESSIONID="+sharedPref.getString("SessionId", ""));
	http = new HttpUtils();
	http.configCurrentHttpCacheExpiry(1000 * 1);
    http.send(arg0,
    		declare.getHost_url() + uri,
    		params,
            new RequestCallBack<String>() {

				@Override
                public void onStart() {
                	Log.i(TAG ,"onStart" ) ;
                }
				
                @Override
                public void onSuccess(ResponseInfo<String> responseInfo) {
                	Log.i(TAG, "Http==>"+responseInfo.result);
					try {
						jsonObject = new JSONObject(responseInfo.result);
						 if(jsonObject.getString("response").equals("error")){
							refresh.refresh(jsonObject.getJSONObject("error").getString("text"), -1);
						 }else if(jsonObject.getString("response").equals("notlogin")){
							 Toast.makeText(context, "登录过期,请重新登录", Toast.LENGTH_SHORT).show();
							 Intent intent = new Intent(context,LogOffACTIVITY.class);
							 intent.putExtra("action", 1);
							 context.startActivity(intent);
						 }else {
							 callback.getResult(jsonObject);
						 }
					} catch (JSONException e) {
						e.printStackTrace();
					}
                }
                @Override
                public void onFailure(HttpException error, String msg) {
                	Log.i(TAG ,"error==>" +  msg ) ;
                	refresh.refresh(msg, -1);
                }
            });
}
 
Example 4
Source File: HttpUtils.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public <T> HttpHandler<T> send(HttpRequest.HttpMethod method, String url,
                               RequestCallBack<T> callBack) {
    return send(method, url, null, callBack);
}
 
Example 5
Source File: HttpUtils.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public ResponseStream sendSync(HttpRequest.HttpMethod method, String url) throws HttpException {
    return sendSync(method, url, null);
}
 
Example 6
Source File: HttpUtils.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public ResponseStream sendSync(HttpRequest.HttpMethod method, String url, RequestParams params) throws HttpException {
    if (url == null) throw new IllegalArgumentException("url may not be null");

    HttpRequest request = new HttpRequest(method, url);
    return sendSyncRequest(request, params);
}
 
Example 7
Source File: HttpUtils.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public HttpHandler<File> download(HttpRequest.HttpMethod method, String url, String target,
                                  RequestParams params, RequestCallBack<File> callback) {
    return download(method, url, target, params, false, false, callback);
}
 
Example 8
Source File: HttpUtils.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public HttpHandler<File> download(HttpRequest.HttpMethod method, String url, String target,
                                  RequestParams params, boolean autoResume, RequestCallBack<File> callback) {
    return download(method, url, target, params, autoResume, false, callback);
}
 
Example 9
Source File: HttpCache.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public boolean isEnabled(HttpRequest.HttpMethod method) {
    if (method == null) return false;

    Boolean enabled = httpMethod_enabled_map.get(method.toString());
    return enabled == null ? false : enabled;
}
 
Example 10
Source File: HttpCache.java    From android-open-project-demo with Apache License 2.0 4 votes vote down vote up
public void setEnabled(HttpRequest.HttpMethod method, boolean enabled) {
    httpMethod_enabled_map.put(method.toString(), enabled);
}