Advertisement
Guest User

Untitled

a guest
May 6th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. signup.setOnClickListener(new View.OnClickListener() {
  2. @Override
  3. public void onClick(View v) {
  4. mail=email.getText().toString();
  5. pass=password.getText().toString();
  6. number = phone.getText().toString();
  7.  
  8. cancel = false;
  9. email.setError(null);
  10. password.setError(null);
  11. phone.setError(null);
  12. focusView=null;
  13.  
  14. if (mail.isEmpty() || mail==null) {
  15. email.setError("This field is required.");
  16. focusView = email;
  17. cancel = true;
  18. } else if (pass.isEmpty() || pass==null || pass.length()<6) {
  19. password.setError("This field is required. Make sure the password length is above 6 characters.");
  20. focusView = password;
  21. cancel = true;
  22. } else if (number.isEmpty()|| number==null) {
  23. phone.setError("This field is required.");
  24. focusView = phone;
  25. cancel = true;
  26. }
  27.  
  28. if (cancel) {
  29. focusView.requestFocus();
  30. }
  31. else{
  32.  
  33. Compare();
  34. }
  35. if(phoneused) {
  36. phone.setError("This phone is already registered to another account, please use your actual phone number.");
  37. focusView = phone;
  38. focusView.requestFocus();
  39. phoneused = false;
  40.  
  41. } else if (mailused) {
  42. email.setError("This mail is already registered to another account, please use another mail.");
  43. focusView = email;
  44. focusView.requestFocus();
  45. mailused = false;
  46.  
  47. } else if (!mailused && !phoneused && !cancel){
  48.  
  49. Log.i("********", list.size()+"");
  50. final ProgressDialog progressDialog = ProgressDialog.show(SignUpActivity.this, "Please wait...", "Proccessing...", true);
  51. mAuth.createUserWithEmailAndPassword(mail, pass)
  52. .addOnCompleteListener(new OnCompleteListener<AuthResult>() {
  53. @Override
  54. public void onComplete(@NonNull Task<AuthResult> task) {
  55. progressDialog.dismiss();
  56.  
  57. if (task.isSuccessful()) {
  58. Toast.makeText(SignUpActivity.this, "Registration successful", Toast.LENGTH_LONG).show();
  59. mAuth.signInWithEmailAndPassword(mail, pass);
  60. FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
  61. if (user != null) {
  62. uid = user.getUid();
  63. mDatabase = mRef.child(uid);
  64. }
  65. mDatabase.child("Email").setValue(mail);
  66. mDatabase.child("Phone").setValue(number);
  67. Intent intent = new Intent(getApplicationContext(), MainActivity.class);
  68. //Bundle extras=new Bundle();
  69. //extras.putString("Email", mail);
  70. //extras.putString("Phone", number);
  71. //intent.putExtras(extras);
  72. startActivity(intent);
  73. finish();
  74. }
  75. }
  76. });
  77. }
  78. }
  79. });
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement