本文整理汇总了Java中com.lidroid.xutils.HttpUtils.send方法的典型用法代码示例。如果您正苦于以下问题:Java HttpUtils.send方法的具体用法?Java HttpUtils.send怎么用?Java HttpUtils.send使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.lidroid.xutils.HttpUtils
的用法示例。
在下文中一共展示了HttpUtils.send方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadData
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void loadData(String url) {
httpUtils = new HttpUtils();
httpUtils.send(HttpRequest.HttpMethod.POST, url, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String json = responseInfo.result;
homeBean = JSON.parseObject(json, HomeBean.class);
List<HomeBean.DataEntity.App_index_recommandEntity> list1 = homeBean.getData().getApp_index_recommand();
if (homeBean != null) {
View headView = getHeadView(inflater);
ptrlistview.getRefreshableView().addHeaderView(headView);
}
list.addAll(list1);
adapter.notifyDataSetChanged();
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(getActivity(), "加载数据失败", Toast.LENGTH_SHORT).show();
View view = ViewStub.inflate(getActivity(),R.layout.faild_layout,null);
}
});
}
示例2: loadData
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void loadData() {
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpRequest.HttpMethod.POST, UrlsConfig.HUODONG_DETAIL_URL, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String json = responseInfo.result;
huoDongBean = JSON.parseObject(json, HuoDongBean.class);
HuoDongBean.DataEntity.Index_activity_itemEntity itemEntivity = huoDongBean.getData().getIndex_activity_item();
bitmapUtils.display(huodong_headview_img,itemEntivity.getImage_url());
huodong_upimg_name.setText(itemEntivity.getName());
huodong_people_time.setText(itemEntivity.getActivity_time_tip() + " " + itemEntivity.getMember_count() + "人参加");
huodong_huodong_detail_textview.setText(itemEntivity.getDesc());
List<HuoDongBean.DataEntity.Activity_share_itemEntity> list1 = huoDongBean.getData().getActivity_share_item();
list.addAll(list1);
adapter.notifyDataSetChanged();
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(getApplicationContext(), "数据加载失败", Toast.LENGTH_SHORT).show();
}
});
}
示例3: loadData
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void loadData(String URL) {
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpRequest.HttpMethod.GET, URL, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String str = responseInfo.result;
SearchGrid searchGrid = JSONObject.parseObject(str, SearchGrid.class);
List<SearchGrid.DataEntity.App_share_dish_list_by_propertyEntity> list = searchGrid.getData().getApp_share_dish_list_by_property();
if (list != null && list.size() > 0) {
datas.addAll(list);
adapter.notifyDataSetChanged();
}
}
@Override
public void onFailure(HttpException e, String s) {
}
});
}
示例4: doDonate
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
void doDonate(int love_id, String money){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("love_id", love_id + "");
params.addBodyParameter("money", money);
HttpUtils httpUtils = new HttpUtils();
httpUtils.configCurrentHttpCacheExpiry(1000);
httpUtils.send(HttpRequest.HttpMethod.POST, ApiStores.donate, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
Toast.makeText(context, "捐赠成功", Toast.LENGTH_SHORT).show();
et_donate.setText("");
getDetails(donation.id);
CenterFragment.instance.getMyInfo();
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(context, "请求失败" + s, Toast.LENGTH_SHORT).show();
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例5: getDetails
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
void getDetails(int donationId){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addQueryStringParameter("love_id", donationId + "");
HttpUtils httpUtils = new HttpUtils();
httpUtils.configCurrentHttpCacheExpiry(1000);
httpUtils.send(HttpRequest.HttpMethod.GET, ApiStores.getDonationDetail, params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
donation = new Gson().fromJson(responseInfo.result, RequestDonation.class).data;
initViews();
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(context, "请求失败", Toast.LENGTH_SHORT).show();
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例6: uploadApply
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
public void uploadApply(final String certificate, final String name, final String position, final String introduction, final String investorsProjects){
RequestParams params = new RequestParams();
params.addHeader("authorization", loginData.getToken());
params.addBodyParameter("certificate", certificate);
params.addBodyParameter("name", name);
params.addBodyParameter("position", position);
params.addBodyParameter("introduction", introduction);
params.addBodyParameter("investorsProjects", investorsProjects);
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpMethod.POST, "http://116.62.228.37:8000/mine/investors", params, new RequestCallBack<String>() {
@Override
public void onSuccess(com.lidroid.xutils.http.ResponseInfo<String> responseInfo) {
Toast.makeText(delegate.getActivity(), "已提交申请", Toast.LENGTH_SHORT).show();
delegate.setStatus(3);
}
@Override
public void onFailure(HttpException e, String s) {
ToastUtil.showToast("uploadFiles failed", delegate.getActivity());
Log.e("aaa", e.getMessage());
Log.e("aaa", s);
}
});
}
示例7: getDataFromServer
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void getDataFromServer() {
HttpUtils httpUtils = new HttpUtils();
httpUtils.send(HttpMethod.GET, mUrl, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result = responseInfo.result;
processData(result);
//���û���
CacheUtils.setCache(mUrl, result, mActivity);
}
@Override
public void onFailure(HttpException error, String msg) {
error.printStackTrace();
Toast.makeText(mActivity, msg, Toast.LENGTH_SHORT).show();
}
});
}
示例8: checkForUpdate
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
/**
* 连接服务器检查更新
*
* @author: cl
* @param context
* @date: 2016-2-19-下午2:45:34
*/
public static void checkForUpdate(Context context) {
UpdateUtil.context = context;
// 连接服务器获取json
// 请求结果会进入缓存,持续时间大概30s,1min内
// 缓存存在期间,请求该链接会直接调用回调函数RequestCallBack,使用缓存中的返回结果
HttpUtils http = new HttpUtils();
http.send(HttpMethod.GET, UpdateUtil.URL_JSON,
new RequestCallBack<String>() {
@Override
public void onFailure(HttpException httpexception, String s) {
Toast.makeText(
UpdateUtil.context,
"无法连接到服务器(" + httpexception.getExceptionCode()
+ ")", Toast.LENGTH_SHORT).show();
}
@Override
public void onSuccess(ResponseInfo<String> responseinfo) {
alertUpdate(responseinfo.result);
}
});
}
示例9: getDataFromServer
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void getDataFromServer() {
HttpUtils utils = new HttpUtils();
utils.send(HttpRequest.HttpMethod.GET, Constants.TOP_STORIES_URL, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result = responseInfo.result;
processResult(result);
PrefUtils.putString(mActivity, Constants.TOP_STORIES_URL, result);
}
@Override
public void onFailure(HttpException e, String s) {
}
});
}
示例10: getNewsDateFromServer
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void getNewsDateFromServer(String itemId) {
final String url = Constants.MENU_NEWS_URL + itemId;
HttpUtils utils = new HttpUtils();
utils.send(HttpRequest.HttpMethod.GET, url, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result = responseInfo.result;
PrefUtils.putString(mActivity, url, result);
processResult(result);
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(mActivity, "网络发生错误", Toast.LENGTH_SHORT).show();
}
});
}
示例11: getDataFromServer
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void getDataFromServer() {
HttpUtils utils = new HttpUtils();
utils.send(HttpRequest.HttpMethod.GET, Constants.SPLASH_URL, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result = responseInfo.result;
PrefUtils.putString(SplashActivity.this, Constants.SPLASH_URL, result);
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(SplashActivity.this, "发生错误", Toast.LENGTH_SHORT).show();
Intent mainIntent = new Intent(SplashActivity.this, MainActivity.class);
startActivity(mainIntent);
finish();
overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
}
});
}
示例12: getDataFromServer
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
/**
* 从服务器获取数据
*/
private void getDataFromServer() {
HttpUtils utils = new HttpUtils();
utils.send(HttpRequest.HttpMethod.GET, GlobalContants.CATEGORIES_URI, new RequestCallBack<String>() {
//访问成功
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result = (String) responseInfo.result;
parseData(result);
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(mActivity, s, Toast.LENGTH_SHORT).show();
e.printStackTrace();
}
});
}
示例13: getJokeList
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
public static void getJokeList(final boolean isRefresh, final int page){
String url = "http://apis.baidu.com/showapi_open_bus/showapi_joke/joke_text";
RequestParams params= new RequestParams();
params.addHeader("apikey", Const.API_KEY);
params.addQueryStringParameter("page", String.valueOf(page));
HttpUtils http = new HttpUtils(10000);
http.send(HttpMethod.GET, url, params, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
Log.i("笑话", responseInfo.result);
Vector<TextJokeEntity> jokeList = JokeParse.parse(responseInfo.result);
Intent intent = new Intent(Const.ACTION_GET_JOKE);
intent.putExtra(Const.KEY_STATUS, Const.GET_JOKE_SUCCESS);
intent.putExtra("isRefresh", isRefresh);
intent.putExtra("jokeList", jokeList);
BaseApplication.getInstance().sendBroadcast(intent);
}
@Override
public void onFailure(HttpException e, String s) {
Log.i("笑话获取失败", e.getMessage() + "");
}
});
}
示例14: getDataFromServer
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
/**
* 从服务器获取数据
*/
private void getDataFromServer() {
HttpUtils utils = new HttpUtils();
// 使用xutils发送请求
utils.send(HttpMethod.GET, GlobalContants.CATEGORIES_URL,
new RequestCallBack<String>() {
// 访问成功
@Override
public void onSuccess(ResponseInfo<String> responseInfo){
String result = (String) responseInfo.result;
System.out.println("返回结果:" + result);
// 解析Gson数据
parseData(result);
}
// 访问失败
@Override
public void onFailure(HttpException error, String msg) {
Toast.makeText(mActivity, msg, Toast.LENGTH_SHORT)
.show();
System.out.println("连接失败");
error.printStackTrace();
}
});
}
示例15: getDataFromServer
import com.lidroid.xutils.HttpUtils; //导入方法依赖的package包/类
private void getDataFromServer() {
HttpUtils utils = new HttpUtils();
utils.send(HttpRequest.HttpMethod.GET, mUri, new RequestCallBack<String>() {
@Override
public void onSuccess(ResponseInfo<String> responseInfo) {
String result = (String) responseInfo.result;
parseData(result,false);
lvList.OnRefreshComplete(true);
}
@Override
public void onFailure(HttpException e, String s) {
Toast.makeText(mActivity, s, Toast.LENGTH_SHORT).show();
e.printStackTrace();
lvList.OnRefreshComplete(false);
}
});
}