public void onEventMainThread(UserInfo userInfo) { int count = mAdapter.getCount(); for (int i = 0; i < count; i++) { UserInfo temp = mAdapter.getItem(i); if (userInfo.getUserId().equals(temp.getUserId())) { temp.setName(userInfo.getName()); temp.setPortraitUri(userInfo.getPortraitUri()); mAdapter.getView( i, mGridList.getChildAt(i - mGridList.getFirstVisiblePosition()), mGridList); } } }
@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 void onDeleteIconClick(View view, final int position) { UserInfo temp = mAdapter.getItem(position); RongIM.getInstance() .getRongIMClient() .removeMemberFromDiscussion( mTargetId, temp.getUserId(), new RongIMClient.OperationCallback() { @Override public void onSuccess() { Message msg = new Message(); msg.what = REMOVE_ITEM; msg.obj = position; getHandler().sendMessage(msg); } @Override public void onError(RongIMClient.ErrorCode errorCode) { getHandler().sendEmptyMessage(SHOW_TOAST); } }); }