Advertisement
Guest User

Untitled

a guest
Jan 10th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. final String email = emailEditText.getText().toString().trim();
  2. String password = passwordEditText.getText().toString().trim();
  3. String passwordVer = rePassword.getText().toString().trim();
  4. final String userPhone = phoneNumEditText.getText().toString().trim();
  5.  
  6.  
  7. if (TextUtils.isEmpty(email)) {
  8.  
  9. Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourEmail), Toast.LENGTH_SHORT).show();
  10. return;
  11. }
  12.  
  13. if (TextUtils.isEmpty(password)) {
  14.  
  15. Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourPassword), Toast.LENGTH_SHORT).show();
  16. return;
  17. }
  18.  
  19. if (TextUtils.isEmpty(passwordVer)) {
  20.  
  21. Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourPassword), Toast.LENGTH_SHORT).show();
  22. return;
  23. }
  24.  
  25. if (TextUtils.isEmpty(userPhone)) {
  26. Toast.makeText(this, getResources().getString(R.string.pleaseEnterYourPhone), Toast.LENGTH_SHORT).show();
  27. return;
  28. }
  29.  
  30.  
  31. if (!TextUtils.equals(password, passwordVer)) {
  32. Toast.makeText(this, getResources().getString(R.string.wrngPwd), Toast.LENGTH_SHORT).show();
  33. return;
  34. }
  35.  
  36.  
  37. firebaseAuth.createUserWithEmailAndPassword(email, password)
  38. .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
  39. @Override
  40. public void onComplete(@NonNull Task<AuthResult> task) {
  41. if (task.isSuccessful()) {
  42. Toast.makeText(regesterAccount.this, getResources().getString(R.string.regestringSucc), Toast.LENGTH_SHORT).show();
  43. //users
  44. User newUser = new User(userName.getText().toString(), userPhone, email);
  45. String uid = FirebaseAuth.getInstance().getCurrentUser().getUid();
  46. fbDatabaseReference.child(uid).setValue(newUser);
  47. finish();
  48. Intent i = new Intent(getApplicationContext(), main.class);
  49. i.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
  50. startActivity(i);
  51. } else {
  52. progressDialog.dismiss();
  53. Toast.makeText(regesterAccount.this, "Error : " + task.getException().getMessage(), Toast.LENGTH_SHORT).show();
  54. }
  55. }
  56. });
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement