@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { UserInfo userInfo = mAdapter.getItem(position); if (userInfo.getUserId().equals("RongDelBtn")) { mAdapter.setDeleteState(true); int count = mAdapter.getCount(); mAdapter.remove(count - 1); mAdapter.remove(count - 2); mAdapter.notifyDataSetChanged(); } else if (userInfo.getUserId().equals("RongAddBtn")) { if (RongContext.getInstance().getMemberSelectListener() == null) { throw new ExceptionInInitializerError("The OnMemberSelectListener hasn't been set!"); } RongContext.getInstance() .getMemberSelectListener() .startSelectMember(getActivity(), mConversationType, mTargetId); } }
@Override public boolean handleMessage(android.os.Message msg) { switch (msg.what) { case PREPARE_LIST: List<String> mMemberInfo = (List<String>) msg.obj; int i = 0; for (String id : mMemberInfo) { if (i < 50) { UserInfo userInfo = RongContext.getInstance().getUserInfoFromCache(id); if (userInfo == null) { mMembers.add(new UserInfo(id, null, null)); } else mMembers.add(userInfo); } else { break; } i++; } UserInfo addBtn = new UserInfo("RongAddBtn", null, null); mMembers.add(addBtn); String curUserId = RongIM.getInstance().getRongIMClient().getCurrentUserId(); if (mAdapter.getCreatorId() != null && mConversationType.equals(Conversation.ConversationType.DISCUSSION) && curUserId.equals(mAdapter.getCreatorId())) { UserInfo deleteBtn = new UserInfo("RongDelBtn", null, null); mMembers.add(deleteBtn); } mAdapter.addCollection(mMembers); mAdapter.notifyDataSetChanged(); break; case REMOVE_ITEM: int position = (Integer) msg.obj; mAdapter.remove(position); mAdapter.notifyDataSetChanged(); break; case SHOW_TOAST: break; } return true; }