Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final String email = emailEditText.getText().toString().trim();
- String password = passwordEditText.getText().toString().trim();
- String passwordVer = rePassword.getText().toString().trim();
- final String userPhone = phoneNumEditText.getText().toString().trim();
- if (TextUtils.isEmpty(email)) {
- Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourEmail), Toast.LENGTH_SHORT).show();
- return;
- }
- if (TextUtils.isEmpty(password)) {
- Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourPassword), Toast.LENGTH_SHORT).show();
- return;
- }
- if (TextUtils.isEmpty(passwordVer)) {
- Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourPassword), Toast.LENGTH_SHORT).show();
- return;
- }
- if (TextUtils.isEmpty(userPhone)) {
- Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourPhone), Toast.LENGTH_SHORT).show();
- return;
- }
- if (!TextUtils.equals(password, passwordVer)) {
- Toast.makeText(this, getResources().getString(R.string.wrngPwd), Toast.LENGTH_SHORT).show();
- return;
- }
- firebaseAuth.createUserWithEmailAndPassword(email, password)
- .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
- @Override
- public void onComplete(@NonNull Task<AuthResult> task) {
- if (task.isSuccessful()) {
- Toast.makeText(regesterAccount.this, getResources().getString(R.string.regestringSucc), Toast.LENGTH_SHORT).show();
- //users
- User newUser = new User(userName.getText().toString(), userPhone, email);
- String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
- fbDatabaseReference.child(uid).setValue(newUser);
- finish();
- Intent i = new Intent(getApplicationContext(), main.class);
- i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
- startActivity(i);
- } else {
- progressDialog.dismiss();
- Toast.makeText(regesterAccount.this, "Error : " + task.getException().getMessage(), Toast.LENGTH_SHORT).show();
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement