SHARE
TWEET

Untitled

a guest Jun 20th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class SignInActivity extends AppCompatActivity  {
  2.  
  3. private EditText SignInMail, SignInPass;
  4. private FirebaseAuth auth;
  5. private Button SignInButton;
  6.  
  7. @Override
  8. protected void onCreate(Bundle savedInstanceState) {
  9.     super.onCreate(savedInstanceState);
  10.  
  11.     //Get Firebase auth instance
  12.     auth = FirebaseAuth.getInstance();
  13.  
  14.  
  15.  
  16.     // set the view now
  17.     setContentView(R.layout.activity_signin);
  18.     SignInMail = (EditText) findViewById(R.id.SignInMail);
  19.     SignInPass = (EditText) findViewById(R.id.SignInPass);
  20.     SignInButton = (Button) findViewById(R.id.SignInButton);
  21.  
  22.     //Get Firebase auth instance
  23.     auth = FirebaseAuth.getInstance();
  24.  
  25.     SignInButton.setOnClickListener(new View.OnClickListener() {
  26.         @Override
  27.         public void onClick(View v) {
  28.             String email = SignInMail.getText().toString();
  29.             final String password = SignInPass.getText().toString();
  30.             if (TextUtils.isEmpty(email)) {
  31.                 Toast.makeText(getApplicationContext(), "Mail", Toast.LENGTH_SHORT).show();
  32.                 return;
  33.             }
  34.             if (TextUtils.isEmpty(password)) {
  35.                 Toast.makeText(getApplicationContext(), "Password", Toast.LENGTH_SHORT).show();
  36.                 return;
  37.             }
  38.             //authenticate user
  39.             auth.signInWithEmailAndPassword(email, password)
  40.                     .addOnCompleteListener(SignInActivity.this, new OnCompleteListener<AuthResult>() {
  41.                         @Override
  42.                         public void onComplete(@NonNull Task<AuthResult> task) {
  43.                             // If sign in fails, display a message to the user. If sign in succeeds
  44.                             // the auth state listener will be notified and logic to handle the
  45.                             // signed in user can be handled in the listener.
  46.                            // progressBar.setVisibility(View.GONE);
  47.                             if (!task.isSuccessful()) {
  48.                                 // there was an error
  49.                                 if (password.length() < 8) {
  50.                                     Toast.makeText(getApplicationContext(),"pass min 8",Toast.LENGTH_SHORT).show();
  51.                                 } else {
  52.                                     Toast.makeText(getApplicationContext(),"error",Toast.LENGTH_SHORT).show();
  53.                                 }
  54.                             } else {
  55.                                 Intent intent = new Intent(SignInActivity.this, CampaignActivity.class);
  56.                                 startActivity(intent);
  57.                                 finish();
  58.                             }
  59.                         }
  60.                     });
  61.         }
  62.     });
  63.  
  64.    }
  65.  
  66.  
  67. public void NavigateSignUp(View v) {
  68.     Intent inent = new Intent(this, SignupActivity.class);
  69.     startActivity(inent);
  70. }
  71. public void NavigateForgetMyPassword(View v) {
  72.     Intent inent = new Intent(this, ResetPasswordActivity.class);
  73.     startActivity(inent);
  74. }
  75. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top