@Override public void handleMessage(Message msg) { super.handleMessage(msg); final NewDataActivity activity = mActivityReference.get(); if (activity == null) { return; } switch (msg.what) { case POST_USER_UPDATE: if (msg.obj == null) { ToastUtil.show(activity, "网络连接不可用,请稍后重试"); } else { try { JSONObject jsonObject = (JSONObject) msg.obj; if (jsonObject.getInt("status") == 200) { Intent intent = new Intent(activity, MenuActivity.class); activity.startActivity(intent); activity.progressBar.setVisibility(View.GONE); } else { activity.progressBar.setVisibility(View.GONE); ToastUtil.show(activity, "提交失败"); activity.userinfo_complete.setClickable(true); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }
@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case NET_GETGROUPS_SUGGEST: String strObject = (String) msg.obj; if (strObject != null) { try { JSONObject jsoninfos = new JSONObject(strObject); if (jsoninfos.getInt("status") == 200) { groups = GroupsConstruct.ToGrouplist(jsoninfos.getJSONArray("data")); if (page != 1 && groups.size() == 0) { ToastUtil.show(GroupSuggestActivity.this, "没有更多团队了"); } else { UpdateUi(groups); } pull_group_suggest.onRefreshComplete(); } else { ToastUtil.show(GroupSuggestActivity.this, jsoninfos.getString("msg")); pull_group_suggest.onRefreshComplete(); } } catch (JSONException e) { ToastUtil.show( GroupSuggestActivity.this, getResources().getString(R.string.errcode_wx)); e.printStackTrace(); pull_group_suggest.onRefreshComplete(); } } else { ToastUtil.show( GroupSuggestActivity.this, getResources().getString(R.string.errcode_wx)); pull_group_suggest.onRefreshComplete(); } progressbar.setVisibility(View.GONE); } }
@Override public void handleMessage(Message msg) { super.handleMessage(msg); switch (msg.what) { case NET_USER_SHOW: String strObject = (String) msg.obj; if (strObject != null && strObject.length() > 10) { try { JSONObject jsonenlist = new JSONObject(strObject); if (jsonenlist.getInt("status") == 200) { user = UsersConstruct.ToUser(jsonenlist.getJSONObject("data")); if (user != null) { getUserInfo(); } } else { ToastUtil.show(UserInfoActivity.this, jsonenlist.getString("msg")); } } catch (JSONException e) { e.printStackTrace(); } } else { ToastUtil.show(UserInfoActivity.this, "网络连接不可用,请稍后重试"); } break; case REMOVE_FRIEND: String removeInfo = (String) msg.obj; if (removeInfo != null) { try { JSONObject jsonenlist = new JSONObject(removeInfo); if (jsonenlist.getInt("status") == 200) { ToastUtil.show(UserInfoActivity.this, "删除好友成功"); UserInfoActivity.this.finish(); EventBus.getDefault().post(new RefreshFriendsList()); // rl_add_friend.setVisibility(View.VISIBLE); // user_addfriend.setVisibility(View.VISIBLE); } else { ToastUtil.show(UserInfoActivity.this, "删除好友失败"); } } catch (JSONException e) { e.printStackTrace(); } } else { ToastUtil.show(UserInfoActivity.this, "网络连接不可用,请稍后重试"); } break; case ADD_FRIEND: String addInfo = (String) msg.obj; if (addInfo != null) { try { JSONObject jsonenlist = new JSONObject(addInfo); if (jsonenlist.getInt("status") == 200) { ToastUtil.show(UserInfoActivity.this, "加好友请求已发送"); user_addfriend.setVisibility(View.GONE); user_invalidation.setVisibility(View.VISIBLE); } else { ToastUtil.show(UserInfoActivity.this, "加好友失败或已添加好友"); } } catch (JSONException e) { e.printStackTrace(); } } else { ToastUtil.show(UserInfoActivity.this, "网络连接不可用,请稍后重试"); } break; case ADD_FRIEND_ACCEPT: String acceptAddInfo = (String) msg.obj; if (acceptAddInfo != null) { try { JSONObject jsonenlist = new JSONObject(acceptAddInfo); if (jsonenlist.getInt("status") == 200) { ToastUtil.show(UserInfoActivity.this, "接受添加好友成功"); rl_add_friend.setVisibility(View.GONE); modify_user_info.setVisibility(View.VISIBLE); } else { ToastUtil.show(UserInfoActivity.this, "接受添加好友失败"); } } catch (JSONException e) { e.printStackTrace(); } } else { ToastUtil.show(UserInfoActivity.this, "网络连接不可用,请稍后重试"); } break; default: break; } }