packageorg.marcinzelent.liberavem;importandroid.content.Intent;importandroid.os.Bundle;importandroid.support.annotation.NonNull;importandroid.support.v7.app.AppCompatActivity;importandroid.text.TextUtils;importandroid.view.View;importandroid.widget.Button;importandroid.widget.EditText;importandroid.widget.ProgressBar;importandroid.widget.Toast;importcom.google.android.gms.tasks.OnCompleteListener;importcom.google.android.gms.tasks.Task;importcom.google.firebase.auth.AuthResult;importcom.google.firebase.auth.FirebaseAuth;publicclassSignupActivityextendsAppCompatActivity{privateEditTextinputEmail,inputPassword;privateButtonbtnSignIn,btnSignUp,btnResetPassword;privateProgressBarprogressBar;privateFirebaseAuthauth;@OverrideprotectedvoidonCreate(BundlesavedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.activity_signup);//Get Firebase auth instanceauth=FirebaseAuth.getInstance();btnSignIn=findViewById(R.id.sign_in_button);btnSignUp=findViewById(R.id.sign_up_button);inputEmail=findViewById(R.id.email);inputPassword=findViewById(R.id.password);progressBar=findViewById(R.id.progressBar);btnResetPassword=findViewById(R.id.btn_reset_password);btnResetPassword.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewv){startActivity(newIntent(SignupActivity.this,ResetPasswordActivity.class));}});btnSignIn.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewv){finish();}});btnSignUp.setOnClickListener(newView.OnClickListener(){@OverridepublicvoidonClick(Viewv){Stringemail=inputEmail.getText().toString().trim();Stringpassword=inputPassword.getText().toString().trim();if(TextUtils.isEmpty(email)){Toast.makeText(getApplicationContext(),"Enter email address!",Toast.LENGTH_SHORT).show();return;}if(TextUtils.isEmpty(password)){Toast.makeText(getApplicationContext(),"Enter password!",Toast.LENGTH_SHORT).show();return;}if(password.length()<6){Toast.makeText(getApplicationContext(),"Password too short, enter minimum 6 characters!",Toast.LENGTH_SHORT).show();return;}progressBar.setVisibility(View.VISIBLE);//create userauth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(SignupActivity.this,newOnCompleteListener<AuthResult>(){@OverridepublicvoidonComplete(@NonNullTask<AuthResult>task){Toast.makeText(SignupActivity.this,"createUserWithEmail:onComplete:"+task.isSuccessful(),Toast.LENGTH_SHORT).show();progressBar.setVisibility(View.GONE);// 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.if(!task.isSuccessful()){Toast.makeText(SignupActivity.this,"Authentication failed."+task.getException(),Toast.LENGTH_SHORT).show();}else{startActivity(newIntent(SignupActivity.this,MainActivity.class));finish();}}});}});}@OverrideprotectedvoidonResume(){super.onResume();progressBar.setVisibility(View.GONE);}}