コード例 #1
0
  private void removeMember(String account) {
    memberAccounts.remove(account);
    for (TeamMemberAdapter.TeamMemberItem item : dataSource) {
      if (account.equals(item.getAccount())) {
        dataSource.remove(item);
        break;
      }
    }
    // 为了解决2.3系统,移除用户后刷新界面不显示的问题
    if (Build.VERSION.SDK_INT < 11) {
      adapter.setMode(TeamMemberAdapter.Mode.NORMAL);
    }

    adapter.notifyDataSetChanged();
  }
コード例 #2
0
  private void updateDataSource() {
    dataSource.clear();

    // member item
    String identity;
    for (String account : memberAccounts) {
      if (creator.equals(account)) {
        identity = TeamMemberHolder.OWNER;
      } else {
        identity = null;
      }
      dataSource.add(
          new TeamMemberAdapter.TeamMemberItem(
              TeamMemberAdapter.TeamMemberItemTag.NORMAL, teamId, account, identity));
    }

    // add item
    dataSource.add(
        new TeamMemberAdapter.TeamMemberItem(
            TeamMemberAdapter.TeamMemberItemTag.ADD, null, null, null));

    // remove item
    if (isSelfAdmin) {
      dataSource.add(
          new TeamMemberAdapter.TeamMemberItem(
              TeamMemberAdapter.TeamMemberItemTag.DELETE, null, null, null));
    }

    // refresh
    adapter.notifyDataSetChanged();
  }
コード例 #3
0
  @Override
  public void onBackPressed() {
    if (adapter.switchMode()) {
      return;
    }

    super.onBackPressed();
  }
コード例 #4
0
  @Override
  public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && adapter.switchMode()) {
      return true;
    }

    return super.onKeyDown(keyCode, event);
  }
コード例 #5
0
 private void initAdapter() {
   memberAccounts = new ArrayList<>();
   dataSource = new ArrayList<>();
   adapter = new TeamMemberAdapter(this, dataSource, this, this, this);
   adapter.setEventListener(this);
 }