void setJobs(String url, ArrayList<ListItem> itemArray) throws URISyntaxException { if (!NetWorkUtil.isNetworkConnected(this.getApplicationContext())) { ToastUtil.show(getApplicationContext(), "网络服务不可用,请检查网络状态!"); return; } List<NameValuePair> list = new ArrayList<NameValuePair>(); if (mBeMyself) list.add(new BasicNameValuePair("name", (String) mUserName.getText())); else list.add(new BasicNameValuePair("name", mOtherName)); HttpResponse res = PostandGetConnectionUtil.getConnect(url, list); if (PostandGetConnectionUtil.responseCode(res) != 200) return; // Toast.makeText(UserProfileActivity.this, // "setJobs", Toast.LENGTH_LONG).show(); String json_str = PostandGetConnectionUtil.GetResponseMessage(res); if (json_str.length() != 0) { JsonPushRet o = new DecodeJson().jsonPush(json_str); itemArray.clear(); if (o.getRet().equals("ok")) { int count = o.getCount(); for (int i = 0; i < count; i++) { String theme = "主题:" + o.getList().get(i).getTheme(); String details = "正文:" + o.getList().get(i).getDetails(); String time = "时间:" + o.getList().get(i).getTime(); String cnt = "人数:" + o.getList().get(i).getCount(); String name = o.getList().get(i).getName(); String img = o.getList().get(i).getImg(); String id = o.getList().get(i).getId(); Bitmap bitmap = mDefaultBit; String image_location = PostandGetConnectionUtil.mediaUrlBase + img; // get the image from the url try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); URL url_image = new URL(image_location); InputStream is = url_image.openStream(); bitmap = RoundImageUtil.toRoundCorner(BitmapFactory.decodeStream(is)); is.close(); } catch (Exception e) { e.printStackTrace(); } itemArray.add(new ListItem(name, theme, time, cnt, details, id, bitmap)); } } } }
void setInfo_other() throws URISyntaxException { if (!NetWorkUtil.isNetworkConnected(this.getApplicationContext())) { ToastUtil.show(getApplicationContext(), "网络服务不可用,请检查网络状态!"); return; } List<NameValuePair> list = new ArrayList<NameValuePair>(); list.add(new BasicNameValuePair("name", mOtherName)); list.add(new BasicNameValuePair("other", "y")); HttpResponse res = PostandGetConnectionUtil.getConnect(PostandGetConnectionUtil.getinfoUrl, list); if (PostandGetConnectionUtil.responseCode(res) != 200) return; String json_str = PostandGetConnectionUtil.GetResponseMessage(res); if (json_str.length() != 0) { JsonInfoResult o = new DecodeJson().jsonInfo(json_str); if (o.getRet().equals("ok")) { mUserName.setText(o.getUsername()); mUserLabel.setText(o.getLabel()); if (o.getSex().equals("F")) { mSexImage.setImageResource(R.drawable.girl); } else { mSexImage.setImageResource(R.drawable.boy); } String image_location = PostandGetConnectionUtil.mediaUrlBase + o.getUserimage(); try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); URL url_image = new URL(image_location); InputStream is = url_image.openStream(); Bitmap bitmap = BitmapFactory.decodeStream(is); photoCh.setImageBitmap(RoundImageUtil.toRoundCorner(bitmap)); is.close(); } catch (Exception e) { e.printStackTrace(); } } } }