Search in sources :

Example 11 with Db

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);
}
Also used : Account(pinkpanthers.pinkshelters.Model.Account) Bundle(android.os.Bundle) ArrayList(java.util.ArrayList) DBI(pinkpanthers.pinkshelters.Model.DBI) Intent(android.content.Intent) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) Homeless(pinkpanthers.pinkshelters.Model.Homeless) RecyclerView(android.support.v7.widget.RecyclerView) Db(pinkpanthers.pinkshelters.Model.Db) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

Db (pinkpanthers.pinkshelters.Model.Db)11 Intent (android.content.Intent)8 Bundle (android.os.Bundle)8 NoSuchUserException (pinkpanthers.pinkshelters.Model.NoSuchUserException)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)4 RecyclerView (android.support.v7.widget.RecyclerView)4 Toolbar (android.support.v7.widget.Toolbar)4 ArrayAdapter (android.widget.ArrayAdapter)4 Button (android.widget.Button)4 View (android.view.View)3 TextView (android.widget.TextView)3 ArrayList (java.util.ArrayList)3 Account (pinkpanthers.pinkshelters.Model.Account)3 DBI (pinkpanthers.pinkshelters.Model.DBI)3 Homeless (pinkpanthers.pinkshelters.Model.Homeless)3 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 AdapterView (android.widget.AdapterView)2 Shelter (pinkpanthers.pinkshelters.Model.Shelter)2 Context (android.content.Context)1