private void getAllShop() { http = new HttpUtils(60 * 1000); boolean connected = BaseUtils.isMobileConnected(ShopActivity.this); if (connected) { showLoading2("数据加载中"); http.send( HttpMethod.GET, GlobalConstant.SHOP_ACTION_GET_ALLSHOP, new RequestCallBack<String>() { @Override public void onFailure(HttpException arg0, String error) { dismissProgressDialog(); XListViewUtil.endload(lvShop); showToast("服务器繁忙,稍后再试"); } @Override public void onSuccess(ResponseInfo<String> info) { dismissProgressDialog(); XListViewUtil.endload(lvShop); System.out.println(info.result); if (info.result.length() > 0) { allshopreturnstr = info.result; fillShopData(info.result); } } }); } else { showToast("网络不可用"); } }
@Override public void onClick(View v) { switch (v.getId()) { case R.id.btn_search: String content = et_shopsearch.getText().toString().trim(); if (TextUtils.isEmpty(content)) { showToast("请输入店铺名称"); return; } boolean connected = BaseUtils.isMobileConnected(ShopActivity.this); if (connected) { showLoading2("数据加载中"); RequestParams params = new RequestParams(); params.addBodyParameter("shop_title", content); Xutils.loadData( HttpMethod.POST, GlobalConstant.SHOP_ACTION_GET_SHOP_SEARCH, params, new RequestCallBack<String>() { @Override public void onFailure(HttpException arg0, String error) { dismissProgressDialog(); showToast("服务器繁忙,稍后再试"); } @Override public void onSuccess(ResponseInfo<String> info) { dismissProgressDialog(); System.out.println(info.result); if (info.result.length() > 0) { fillShopData(info.result); } } }); } else { showToast("网络不可用"); } break; default: break; } }
/** 根据宿舍栋编号获取宿舍信息 */ private void fillData() { if (!BaseUtils.isNetWork(getApplicationContext())) { showToast("请检查您的网络"); return; } showLoading2("正在加载"); RequestParams params = new RequestParams(); params.addBodyParameter("supmaket_id", supmaket_id); loadData( HttpMethod.POST, GlobalConstant.GET_APPLY_SUPMARKET_PROXY_HOSTEL, params, new RequestCallBack<String>() { @Override public void onFailure(HttpException arg0, String arg1) { dismissProgressDialog(); showToast("加载失败"); } @Override public void onSuccess(ResponseInfo<String> info) { dismissProgressDialog(); try { JSONObject object = new JSONObject(info.result); String schoolName = object.getString("school_name"); String hostelName = object.getString("hostel_name"); tv_my_apply_proxy_title.setText("申请代理信息:"); tv_my_apply_proxy_info.setText("学校:" + schoolName); tv_my_apply_proxy_hostel.setText("宿舍:" + hostelName); tv_apply_proxy_status.setText("审核状态:审核中"); } catch (JSONException e) { e.printStackTrace(); } } }); }
@Override public void initdata() { if (!BaseUtils.isNetWork(getApplicationContext())) { showToast("请检查您的网络"); return; } showLoading2("正在加载"); RequestParams params = new RequestParams(); params.addBodyParameter("drepair_id", dpid + ""); loadData( HttpMethod.POST, GlobalConstant.GET_DIGITAL_INFO_BY_ID, params, new RequestCallBack<String>() { @Override public void onSuccess(ResponseInfo<String> response) { dismissProgressDialog(); String returnstr = response.result; Log.v(TAG, response.result); if (TextUtils.isEmpty(returnstr)) { showToast("加载失败"); } else { try { JSONObject json = new JSONObject(returnstr); int id = json.getInt("id"); String title = json.getString("title"); String detail = json.getString("detail"); String company_name = json.getString("company_name"); String company_address = json.getString("company_address"); company_phone = json.getString("company_phone"); int status = json.getInt("status"); String company_log1 = json.getString("company_log1"); String company_log2 = json.getString("company_log2"); String company_log3 = json.getString("company_log3"); final String[] urls = new String[3]; urls[0] = company_log1; urls[1] = company_log2; urls[2] = company_log3; if (!TextUtils.isEmpty(company_log1)) { event_pic1.setVisibility(View.VISIBLE); ImageLoader.getInstance() .displayImage(company_log1, event_pic1, ImageLoaderOption.getoption()); event_pic1.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { ImageUtil.toShowImages(DigitalRepairDetailActivity.this, urls, 0); } }); } else { event_pic1.setVisibility(View.INVISIBLE); } if (!TextUtils.isEmpty(company_log2)) { event_pic2.setVisibility(View.VISIBLE); ImageLoader.getInstance() .displayImage(company_log2, event_pic2, ImageLoaderOption.getoption()); event_pic2.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { ImageUtil.toShowImages(DigitalRepairDetailActivity.this, urls, 1); } }); } else { event_pic2.setVisibility(View.INVISIBLE); } if (!TextUtils.isEmpty(company_log3)) { event_pic3.setVisibility(View.VISIBLE); ImageLoader.getInstance() .displayImage(company_log3, event_pic3, ImageLoaderOption.getoption()); event_pic3.setOnClickListener( new OnClickListener() { @Override public void onClick(View arg0) { ImageUtil.toShowImages(DigitalRepairDetailActivity.this, urls, 2); } }); } else { event_pic3.setVisibility(View.INVISIBLE); } activity_digitalrepair_detail_title.setText(title); activity_digitalrepair_detail_detail.setText("\t" + detail); activity_digitalrepair_detail_companyname.setText(company_name); activity_digitalrepair_detail_address.setText("地址:" + company_address); activity_digitalrepair_detail_phone.setText("预约电话:" + company_phone); } catch (JSONException e) { showToast("加载失败"); e.printStackTrace(); } } } @Override public void onFailure(HttpException arg0, String arg1) { dismissProgressDialog(); showToast("加载失败"); } }); }