use of com.example.peter.homelessapp.model.Administer in project FindMyHome by DjangoBlockchained.
the class RegisterScreenActivity method onCreate.
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register_screen);
name = findViewById(R.id.regName);
username = findViewById(R.id.regUserName);
password1 = findViewById(R.id.regPass1);
password2 = findViewById(R.id.regPass2);
adminBox = findViewById(R.id.checkBox);
Button cancel = findViewById(R.id.cancel2);
cancel.setOnClickListener((view) -> finish());
Button register = findViewById(R.id.registerUser);
register.setOnClickListener((view) -> {
if ((name.getText().length() == 0) || (username.getText().length() == 0) || (password1.getText().length() == 0) || (password2.getText().length() == 0)) {
showEmptyFieldsAlert();
} else if (password1.getText().toString().equals(password2.getText().toString())) {
if (validUserName(username.getText().toString())) {
if (adminBox.isChecked()) {
Administer newUser = new Administer(name.getText().toString(), username.getText().toString(), password1.getText().toString());
Intent intent = new Intent(RegisterScreenActivity.this, AdminScreenActivity.class);
intent.putExtra("admin", username.getText().toString());
startActivity(intent);
} else {
HomelessUser newUser = new HomelessUser(name.getText().toString(), username.getText().toString(), password1.getText().toString());
Intent intent = new Intent(RegisterScreenActivity.this, ApplicationScreenActivity.class);
intent.putExtra("username", username.getText().toString());
startActivity(intent);
}
} else {
showTakenUsernameAlert();
}
} else {
showMismatchedPasswordsAlert();
}
});
}
Aggregations