@Override protected void deleteUserReceive(User user) { if (user == null) return; Toast.makeText(this, (user.getName() == null) ? user.getJID() : user.getName() + "被删除了", Toast.LENGTH_SHORT).show(); refreshList(); }
@Override public void onItemClick(AdapterView<?> arg0, View view, int arg2, long arg3) { final Notice notice = (Notice) view.findViewById(R.id.new_content) .getTag(); if (notice.getNoticeType() == Notice.CHAT_MSG) { User user = new User(); user.setJID("[email protected]"); createChat(user); } else { final String subFrom = notice.getFrom(); new AlertDialog.Builder(ContacterMainActivity.this) .setMessage(subFrom + "请求添加您为好友") .setTitle("提示") .setPositiveButton("添加", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sendSubscribe(Presence.Type.subscribed, subFrom); sendSubscribe(Presence.Type.subscribe, subFrom); refreshList(); } }) .setNegativeButton("拒绝", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { sendSubscribe( Presence.Type.unsubscribe, subFrom); } }).show(); } }
@Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { switch (v.getId()) { case R.id.main_expand_list: ExpandableListView.ExpandableListContextMenuInfo info = (ExpandableListView.ExpandableListContextMenuInfo) menuInfo; int type = ExpandableListView .getPackedPositionType(info.packedPosition); if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) { int gId = ExpandableListView .getPackedPositionGroup(info.packedPosition); String[] longClickItems = null; final String groupName = rGroups.get(gId).getName(); if (StringUtil.notEmpty(groupName) && !Constant.ALL_FRIEND.equals(groupName) && !Constant.NO_GROUP_FRIEND.equals(groupName)) { longClickItems = new String[] { "添加分组", "更改组名", }; } else { longClickItems = new String[] { "添加分组" }; } new AlertDialog.Builder(ContacterMainActivity.this) .setItems(longClickItems, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog, int which) { switch (which) { case 0: addNewGroup(); break; case 1: updateGroupNameA(groupName); break; } } }).setTitle("选项").show(); } else if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) { String[] longClickItems = null; View vx = info.targetView; clickUser = (User) vx.findViewById(R.id.username).getTag(); showToast(clickUser.getJID() + "---"); if (StringUtil.notEmpty(clickUser.getGroupName()) && !Constant.ALL_FRIEND.equals(clickUser .getGroupName()) && !Constant.NO_GROUP_FRIEND.equals(clickUser .getGroupName())) { longClickItems = new String[] { "设置昵称", "添加好友", "删除好友", "移动到分组", "退出该组" }; } else { longClickItems = new String[] { "设置昵称", "添加好友", "删除好友", "移动到分组" }; } new AlertDialog.Builder(ContacterMainActivity.this) .setItems(longClickItems, new DialogInterface.OnClickListener() { @Override public void onClick( DialogInterface dialog, int which) { switch (which) { case 0: setNickname(clickUser); break; case 1: addSubscriber(); break; case 2: showDeleteDialog(clickUser); break; case 3: removeUserFromGroupUI(clickUser); removeUserFromGroup(clickUser, clickUser.getGroupName()); addToGroup(clickUser); break; case 4: removeUserFromGroupUI(clickUser); removeUserFromGroup(clickUser, clickUser.getGroupName()); break; } } }).setTitle("选项").show(); } break; case R.id.main_chat_room_list: String[] longClickItems = new String[] { "创建房间", "删除房间", "邀请好友", "房间改名" }; new AlertDialog.Builder(ContacterMainActivity.this) .setItems(longClickItems, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: addChatRoom(); break; case 1: break; case 2: break; case 3: break; } } }).setTitle("选项").show(); break; default: break; } }
@Override protected void changePresenceReceive(User user) { if (user == null) return; if (ContacterManager.contacters.get(user.getJID()) == null) return; if (!user.isAvailable()) if (ContacterManager.contacters.get(user.getJID()).isAvailable()) Toast.makeText(this, (user.getName() == null) ? user.getJID() : user .getName() + "上线了", Toast.LENGTH_SHORT).show(); if (user.isAvailable()) if (!ContacterManager.contacters.get(user.getJID()).isAvailable()) Toast.makeText(this, (user.getName() == null) ? user.getJID() : user .getName() + "下线了", Toast.LENGTH_SHORT).show(); refreshList(); }