Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class SignInActivity extends AppCompatActivity {
- private EditText SignInMail, SignInPass;
- private FirebaseAuth auth;
- private Button SignInButton;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- //Get Firebase auth instance
- auth = FirebaseAuth.getInstance();
- // set the view now
- setContentView(R.layout.activity_signin);
- SignInMail = (EditText) findViewById(R.id.SignInMail);
- SignInPass = (EditText) findViewById(R.id.SignInPass);
- SignInButton = (Button) findViewById(R.id.SignInButton);
- //Get Firebase auth instance
- auth = FirebaseAuth.getInstance();
- SignInButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- String email = SignInMail.getText().toString();
- final String password = SignInPass.getText().toString();
- if (TextUtils.isEmpty(email)) {
- Toast.makeText(getApplicationContext(), "Mail", Toast.LENGTH_SHORT).show();
- return;
- }
- if (TextUtils.isEmpty(password)) {
- Toast.makeText(getApplicationContext(), "Password", Toast.LENGTH_SHORT).show();
- return;
- }
- //authenticate user
- auth.signInWithEmailAndPassword(email, password)
- .addOnCompleteListener(SignInActivity.this, new OnCompleteListener<AuthResult>() {
- @Override
- public void onComplete(@NonNull Task<AuthResult> task) {
- // If sign in fails, display a message to the user. If sign in succeeds
- // the auth state listener will be notified and logic to handle the
- // signed in user can be handled in the listener.
- // progressBar.setVisibility(View.GONE);
- if (!task.isSuccessful()) {
- // there was an error
- if (password.length() < 8) {
- Toast.makeText(getApplicationContext(),"pass min 8",Toast.LENGTH_SHORT).show();
- } else {
- Toast.makeText(getApplicationContext(),"error",Toast.LENGTH_SHORT).show();
- }
- } else {
- Intent intent = new Intent(SignInActivity.this, CampaignActivity.class);
- startActivity(intent);
- finish();
- }
- }
- });
- }
- });
- }
- public void NavigateSignUp(View v) {
- Intent inent = new Intent(this, SignupActivity.class);
- startActivity(inent);
- }
- public void NavigateForgetMyPassword(View v) {
- Intent inent = new Intent(this, ResetPasswordActivity.class);
- startActivity(inent);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement