public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mGridList.setAdapter(mAdapter); mGridList.setOnItemClickListener(this); mGridList.setOnTouchListener( new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if (MotionEvent.ACTION_UP == event.getAction() && mAdapter.isDeleteState()) { UserInfo addBtn = new UserInfo("RongAddBtn", null, null); mAdapter.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); mAdapter.add(deleteBtn); } mAdapter.setDeleteState(false); mAdapter.notifyDataSetChanged(); return true; } return false; } }); }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent; RongContext.getInstance().getEventBus().register(this); if (getActivity() != null) { intent = getActivity().getIntent(); if (intent.getData() != null) { mConversationType = Conversation.ConversationType.valueOf( intent.getData().getLastPathSegment().toUpperCase()); mTargetId = intent.getData().getQueryParameter("targetId"); } } mAdapter = new RongConversationAddMemberAdapter(getActivity()); mAdapter.setDeleteIconListener(this); if (RongIM.getInstance() != null && RongIM.getInstance().getRongIMClient() != null) { initData(); } }