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(); }
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(); }
@Override public void onBackPressed() { if (adapter.switchMode()) { return; } super.onBackPressed(); }
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_BACK && adapter.switchMode()) { return true; } return super.onKeyDown(keyCode, event); }
private void initAdapter() { memberAccounts = new ArrayList<>(); dataSource = new ArrayList<>(); adapter = new TeamMemberAdapter(this, dataSource, this, this, this); adapter.setEventListener(this); }