use of com.hci.carebase.domain.Summary in project Carebase by robertsimoes.
the class LoginRegisterActivity method onExecSignUpButtonClick.
@OnClick(R.id.vs_signup_button_exec_signup)
public void onExecSignUpButtonClick(View v) {
PatientSource src = CollectionsProvider.patients();
if (signup_signUpPasswordEt.getText().toString().equals(signup_signUpConfirmEt.getText().toString())) {
progressDialog = ProgressDialog.show(this, "Please wait...", "Processing...", true);
(fauth.createUserWithEmailAndPassword(signup_signUpEmailEt.getText().toString(), signup_signUpPasswordEt.getText().toString())).addOnCompleteListener(task -> {
progressDialog.dismiss();
if (task.isSuccessful()) {
Toast.makeText(this, "Registration successful", Toast.LENGTH_LONG).show();
String uid = fauth.getUid();
cache.storeUserId(uid);
Doctor d = new Doctor(signup_signUpDoctorFnameEt.getText().toString(), signup_signUpDoctorLnameEt.getText().toString());
Appointment a = new Appointment(new Date(), "University Hospital", d, "", "");
Calendar c = Calendar.getInstance();
c.add(Calendar.YEAR, 1);
Date finishDate = c.getTime();
Patient p = new Patient(signup_patient_fname.getText().toString(), signup_patient_lname.getText().toString(), signup_signUpHCardNum.getText().toString(), d, new ArrayList<Appointment>() {
{
add(a);
}
}, new ArrayList<Summary>() {
{
add(Faker.fakeSummary());
}
}, new ArrayList<Prescription>() {
{
add(Faker.fakeScript());
}
}, Faker.fakeInfo(), finishDate);
src.createPatient(p, uid, task1 -> {
if (task1.isSuccessful()) {
Intent intent = new Intent(this, IntroActivity.class);
startActivity(intent);
finish();
} else {
Toast.makeText(this, task1.getException().getMessage() != null ? task1.getException().getMessage() : "Error signing up, please try again", Toast.LENGTH_LONG).show();
}
});
} else {
Toast.makeText(this, task.getException().getMessage() != null ? task.getException().getMessage() : "Error signing up, please try again", Toast.LENGTH_LONG).show();
}
});
} else {
Toast.makeText(this, "Passwords not equal!", Toast.LENGTH_LONG).show();
signup_signUpPasswordEt.getText().clear();
signup_signUpConfirmEt.getText().clear();
}
}
Aggregations