use of pinkpanthers.pinkshelters.Model.Restrictions in project pink-panthers by MrTrai.
the class UserInfoActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.user_info_page);
// set up check box restrictions
buttonStatus = findViewById(R.id.status);
buttonStatus.setVisibility(View.INVISIBLE);
List<String> currentRestrictionList;
checkBoxList = new ArrayList<>();
checkBoxList.add((CheckBox) findViewById(R.id.checkBox1));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox2));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox3));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox4));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox5));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox6));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox7));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox8));
checkBoxList.add((CheckBox) findViewById(R.id.checkBox9));
enums = Arrays.asList(Restrictions.values());
try {
getUserAccount();
} catch (NoSuchUserException e) {
e.printStackTrace();
}
if (account instanceof Homeless) {
homeless = (Homeless) account;
currentRestrictionList = ((Homeless) account).getRestrictionsMatch();
if (currentRestrictionList != null) {
for (int i = 0; i < currentRestrictionList.size(); i++) {
for (int j = 0; j < checkBoxList.size(); j++) {
CheckBox item = checkBoxList.get(j);
if (!item.isChecked()) {
Restrictions restrictions = enums.get(j);
boolean isCheck = checkCheckbox(currentRestrictionList.get(i), restrictions.toString());
item.setChecked(isCheck);
}
}
}
}
}
// add choices to family size
for (int i = 1; i < 16; i++) {
familySizeList.add(i);
}
family_spinner = findViewById(R.id.family_spinner);
ArrayAdapter<Integer> family_adapter = new ArrayAdapter<>(this, android.R.layout.simple_spinner_item, familySizeList);
family_adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
family_spinner.setAdapter(family_adapter);
family_spinner.setSelection(homeless.getFamilyMemberNumber() - 1);
// Spinner click listener for family size
family_spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
Object item = family_spinner.getSelectedItem();
familySize = Integer.valueOf(item.toString());
}
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
// nothing happens when nothing is selected
}
});
// Grab name and user type to show in homepage
TextView name = findViewById(R.id.accountUserName);
TextView email = findViewById(R.id.email);
// Display name and email
name.setText("Name: " + account.getName());
email.setText("Email: " + account.getEmail());
}
use of pinkpanthers.pinkshelters.Model.Restrictions in project pink-panthers by MrTrai.
the class UserInfoActivity method updateRestrictionList.
/**
* When checkbox is clicked, add restriction to list.
*/
private void updateRestrictionList() {
for (int i = 0; i < checkBoxList.size(); i++) {
CheckBox item = checkBoxList.get(i);
if (item.isChecked()) {
Restrictions restrictions = enums.get(i);
restrictionList.add(restrictions.toString());
}
}
}
Aggregations