private void netdelete() { // 判断是否登录 String userID = SPUtils.getUserID(context); if (TextUtils.isEmpty(userID)) { Intent intent = new Intent(context, LoagingActivity.class); startActivity(intent); } else { boolean connection = NetworkUtils.isConnection(context); if (!connection) { showWords("当前网络不可用,请你检查网络的情况"); return; } utils.show(); NetHead head = new NetHead(context); RequestParams params = head.setHeader(); params.addBodyParameter("houseId", mListBean.get(deleteTag).sid); params.addBodyParameter("type", "deleteColect"); params.addBodyParameter("userId", SPUtils.getUserID(context)); if (http == null) { http = new HttpUtils(); } http.send( HttpMethod.POST, UrlsUtils.urls, params, new RequestCallBack<String>() { @Override public void onFailure(HttpException arg0, String arg1) { utils.closeDialog(); Toast.makeText(context, StreamTools.getString(), Toast.LENGTH_SHORT).show(); } @Override public void onSuccess(ResponseInfo<String> arg0) { utils.closeDialog(); mListBean.remove(deleteTag); if (mListBean.size() == 0) { showWords((String) getResources().getText(R.string.collection_house)); } adapter.notifyDataSetChanged(); String result = arg0.result; JSONObject josn = null; try { josn = new JSONObject(result); String statue = josn.getString("status"); if (!"N".equals(statue)) { Toast.makeText(context, "删除成功", Toast.LENGTH_SHORT).show(); } } catch (Exception e) { e.printStackTrace(); } } }); } }
private void network() { boolean connected = NetworkUtils.isConnection(getActivity()); if (connected) { // 访问网络 utils = new DialogUtils(getActivity()); utils.show(); NetHead head = new NetHead(getActivity()); RequestParams params = head.setHeader(); params.addBodyParameter("type", "queryCollect"); params.addBodyParameter("userId", SPUtils.getUserID(getActivity())); params.addBodyParameter("houseT", "1"); if (http == null) { http = new HttpUtils(); } http.send( HttpMethod.POST, UrlsUtils.urls, params, new RequestCallBack<String>() { @Override public void onFailure(HttpException arg0, String arg1) { Toast.makeText(getActivity(), StreamTools.getString(), Toast.LENGTH_SHORT).show(); utils.closeDialog(); colseHeard(); } @Override public void onSuccess(ResponseInfo<String> arg0) { colseHeard(); mResult = arg0.result; utils.closeDialog(); praseJson(); } }); } else { // Toast.makeText(getActivity(), "当前网络不可用,请你检查网络的情况", Toast.LENGTH_SHORT).show(); showWords("当前网络不可用,请你检查网络的情况"); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_release); context = ReleaseActivity.this; // 判断是否登陆了 userID = SPUtils.getUserID(getBaseContext()); if (userID == null) { Intent intent = new Intent(this, LoagingActivity.class); startActivity(intent); } dir = ReleaseActivity.this.getFilesDir(); // 初始化控件 initView(); Intent intentFrom = getIntent(); if ("求租".equals(intentFrom.getExtras().getString("from"))) { flag = true; tenantId = intentFrom.getExtras().getString("tenantId"); loadInfo(); } }