private void refreshMembers() {
    adapter.clear();

    List<String> members = new ArrayList<String>();
    members.addAll(group.getMembers());
    adapter.addAll(members);

    adapter.notifyDataSetChanged();
  }
 private void showGroupDetail() {
   progressBar.setVisibility(View.INVISIBLE);
   // 获取详情成功,并且自己不在群中,才让加入群聊按钮可点击
   if (!group.getMembers().contains(EMChatManager.getInstance().getCurrentUser()))
     btn_add_group.setEnabled(true);
   tv_name.setText(group.getGroupName());
   tv_admin.setText(group.getOwner());
   tv_introduction.setText(group.getDescription());
 }
Ejemplo n.º 3
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_group_pick_contacts);

    // String groupName = getIntent().getStringExtra("groupName");
    String groupId = getIntent().getStringExtra("groupId");
    if (groupId == null) { // 创建群组
      isCreatingNewGroup = true;
    } else {
      // 获取此群组的成员列表
      EMGroup group = EMGroupManager.getInstance().getGroup(groupId);
      exitingMembers = group.getMembers();
    }
    if (exitingMembers == null) exitingMembers = new ArrayList<String>();
    // 获取好友列表
    final List<User> alluserList = new ArrayList<User>();
    for (User user : BeewayApplication.getInstance().getContactList().values()) {
      if (!user.getUsername().equals(Constant.NEW_FRIENDS_USERNAME)
          & !user.getUsername().equals(Constant.GROUP_USERNAME)
          & !user.getUsername().equals(Constant.CHAT_ROOM)
          & !user.getUsername().equals(Constant.CHAT_ROBOT)) alluserList.add(user);
    }
    friendDao = new FriendDao(this);
    // 对list进行排序
    Collections.sort(
        alluserList,
        new Comparator<User>() {
          @Override
          public int compare(User lhs, User rhs) {
            return (friendDao.getFriend(lhs.getUsername()).getLetter())
                .compareTo(friendDao.getFriend(rhs.getUsername()).getLetter());
            //				return (lhs.getUsername().compareTo(rhs.getUsername()));

          }
        });

    listView = (ListView) findViewById(R.id.list);
    contactAdapter = new PickContactAdapter(this, R.layout.row_contact_with_checkbox, alluserList);
    listView.setAdapter(contactAdapter);
    ((Sidebar) findViewById(R.id.sidebar)).setListView(listView);
    listView.setOnItemClickListener(
        new OnItemClickListener() {

          @Override
          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            CheckBox checkBox = (CheckBox) view.findViewById(R.id.checkbox);
            checkBox.toggle();
          }
        });
  }
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // 获取传过来的groupid
    groupId = getIntent().getStringExtra("groupId");
    group = EMGroupManager.getInstance().getGroup(groupId);

    // we are not supposed to show the group if we don't find the group
    if (group == null) {
      finish();
      return;
    }

    setContentView(RHelper.get("layout.em_activity_group_details"));
    instance = this;
    st = getResources().getString(RHelper.get("string.people"));
    clearAllHistory = (RelativeLayout) findViewById(RHelper.get("id.clear_all_history"));
    userGridview = (EaseExpandGridView) findViewById(RHelper.get("id.gridview"));
    loadingPB = (ProgressBar) findViewById(RHelper.get("id.progressBar"));
    exitBtn = (Button) findViewById(RHelper.get("id.btn_exit_grp"));
    deleteBtn = (Button) findViewById(RHelper.get("id.btn_exitdel_grp"));
    blacklistLayout = (RelativeLayout) findViewById(RHelper.get("id.rl_blacklist"));
    changeGroupNameLayout = (RelativeLayout) findViewById(RHelper.get("id.rl_change_group_name"));
    idLayout = (RelativeLayout) findViewById(RHelper.get("id.rl_group_id"));
    idLayout.setVisibility(View.VISIBLE);
    idText = (TextView) findViewById(RHelper.get("id.tv_group_id_value"));

    rl_switch_block_groupmsg =
        (RelativeLayout) findViewById(RHelper.get("id.rl_switch_block_groupmsg"));
    switchButton = (EaseSwitchButton) findViewById(RHelper.get("id.switch_btn"));

    rl_switch_block_groupmsg.setOnClickListener(this);

    idText.setText(groupId);
    if (group.getOwner() == null
        || "".equals(group.getOwner())
        || !group.getOwner().equals(EMChatManager.getInstance().getCurrentUser())) {
      exitBtn.setVisibility(View.GONE);
      deleteBtn.setVisibility(View.GONE);
      blacklistLayout.setVisibility(View.GONE);
      changeGroupNameLayout.setVisibility(View.GONE);
    }
    // 如果自己是群主,显示解散按钮
    if (EMChatManager.getInstance().getCurrentUser().equals(group.getOwner())) {
      exitBtn.setVisibility(View.GONE);
      deleteBtn.setVisibility(View.VISIBLE);
    }

    groupRemoveListener = new GroupRemoveListener();
    EMGroupManager.getInstance().addGroupChangeListener(groupRemoveListener);

    ((TextView) findViewById(RHelper.get("id.group_name")))
        .setText(group.getGroupName() + "(" + group.getAffiliationsCount() + st);

    List<String> members = new ArrayList<String>();
    members.addAll(group.getMembers());

    adapter = new GridAdapter(this, RHelper.get("layout.em_grid"), members);
    userGridview.setAdapter(adapter);

    // 保证每次进详情看到的都是最新的group
    updateGroup();

    // 设置OnTouchListener
    userGridview.setOnTouchListener(
        new OnTouchListener() {

          @Override
          public boolean onTouch(View v, MotionEvent event) {
            switch (event.getAction()) {
              case MotionEvent.ACTION_DOWN:
                if (adapter.isInDeleteMode) {
                  adapter.isInDeleteMode = false;
                  adapter.notifyDataSetChanged();
                  return true;
                }
                break;
              default:
                break;
            }
            return false;
          }
        });

    clearAllHistory.setOnClickListener(this);
    blacklistLayout.setOnClickListener(this);
    changeGroupNameLayout.setOnClickListener(this);
  }