use of ca.dal.cs.athletemonitor.athletemonitor.adapters.TeamMembersAdapter in project SEProject by NicholasBarreyre.
the class TeamDetailActivity method populateMemberList.
/**
* Populates the list of teams associated with the user
*/
private void populateMemberList() {
final ListView teamMemberListView = findViewById(R.id.memberList);
// retrieve database reference to the team members
FirebaseDatabase database = FirebaseDatabase.getInstance();
DatabaseReference teamsReference = database.getReference("teams/" + team.getId() + "/teamMembers");
teamMemberAdapter = new TeamMembersAdapter(this, new ArrayList<String>());
teamsReference.addChildEventListener(new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
teamMemberAdapter.add(dataSnapshot.getValue(String.class));
}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
teamMemberAdapter.remove(dataSnapshot.getValue(String.class));
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
teamMemberListView.setAdapter(teamMemberAdapter);
teamMemberListView.setOnItemClickListener(new TeamDetailActivity.TeamMemberListClickListener());
}
Aggregations