use of pinkpanthers.pinkshelters.Model.Db in project pink-panthers by MrTrai.
the class AllHomelessActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.layout);
Toolbar title = findViewById(R.id.titleBar);
title.setTitle("Current Residents");
// data to populate the RecyclerView with
ArrayList<String> accountNames = new ArrayList<>();
DBI db = new Db("pinkpanther", "PinkPantherReturns!");
accounts = db.getAllAccounts();
Intent intent = getIntent();
Bundle extras = intent.getExtras();
assert extras != null;
int shelterId = extras.getInt("shelterId");
for (Account account : accounts) {
if (account instanceof Homeless) {
if (((Homeless) account).getShelterId() == shelterId) {
accountNames.add(account.getName());
}
}
}
// set up the RecyclerView
RecyclerView recyclerView = findViewById(R.id.rvShelters);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
RecyclerAdapter adapter = new RecyclerAdapter(this, accountNames);
adapter.setClickListener(this);
recyclerView.setAdapter(adapter);
}
Aggregations