package com.casic.gasoperation.config; import android.content.Context; import com.loopj.android.http.AsyncHttpClient; import com.loopj.android.http.AsyncHttpResponseHandler; import com.loopj.android.http.RequestParams; import com.casic.gasoperation.mmu.ContextUtil; import com.casic.gasoperation.mmu.SharePreferenceUtil; import com.casic.gasoperation.model.Constants; /** * wechat * * @author donal * */ public class RestClient { private static AsyncHttpClient client = new AsyncHttpClient(); static SharePreferenceUtil util; static Context c = ContextUtil.getInstance(); public static AsyncHttpClient getIntance() { return client; } public static void get(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { client.get(getAbsoluteUrl(url), params, responseHandler); } public static void getWeb(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { client.get(context, url, params, responseHandler); } public static void post(String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { client.post(getAbsoluteUrl(url), params, responseHandler); } public static void post(Context context, String url, RequestParams params, AsyncHttpResponseHandler responseHandler) { client.post(context, getAbsoluteUrl(url), params, responseHandler); } public static String getAbsoluteUrl(String relativeUrl) { client.setTimeout(10*1000); client.setMaxConnections(50); util = new SharePreferenceUtil(c , Constants.SAVE_USER); //ip地址 return "http://111.198.10.15:11630" + relativeUrl; // return "http://139.198.6.177:14500" + relativeUrl; } public static String getAbsoluteUrl() { return "http://111.198.10.15:11630" ; // return "http://139.198.6.177:14500" ; } }