package @Override public void onClick(View v) { final String

package com.example.hamza.hamari_sawari; import android.content.Intent; import android.support.annotation.NonNull; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.text.InputType; import android.view.View; import android.widget.Button; import android.widget.CheckBox; import android.widget.CompoundButton; import android.widget.EditText; import android.widget.Toast; import com.google.android.gms.tasks.OnCompleteListener; import com.google.android.gms.tasks.Task; import com.google.firebase.auth.AuthResult; import com.google.firebase.auth.FirebaseAuth; import com.google.firebase.auth.FirebaseUser; import com.google.firebase.database.DatabaseReference; import com.google.firebase.database.FirebaseDatabase;public class CustomerLoginActivity extends AppCompatActivity { private EditText mEmail, mPassword; private Button mLogin, mRegistration; private FirebaseAuth mAuth; private CheckBox mChkk; private FirebaseAuth.AuthStateListener firebaseAuthListener; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_customer_login); mAuth = FirebaseAuth.getInstance(); firebaseAuthListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser(); if(user!=null){ Intent intent = new Intent(CustomerLoginActivity.this, CustomerMapActivity.class); startActivity(intent); finish(); return; } } }; mChkk = (CheckBox) findViewById(R.id.chkk); mEmail = (EditText) findViewById(R.id.email); mPassword = (EditText) findViewById(R.id.password); mLogin = (Button) findViewById(R.id.login); mRegistration = (Button) findViewById(R.id.registration); mChkk.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean b) { if (b){ mPassword.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD); } else { mPassword.setInputType(InputType.TYPE_CLASS_TEXT|InputType .TYPE_TEXT_VARIATION_PASSWORD); } } }); mRegistration.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String email = mEmail.getText().toString(); final String password = mPassword.getText().toString(); mAuth.createUserWithEmailAndPassword(email, password).addOnCompleteListener(CustomerLoginActivity.this, new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if(!task.isSuccessful()){ Toast.makeText(CustomerLoginActivity.this, “sign up error”, Toast.LENGTH_SHORT).show(); }else{ String user_id = mAuth.getCurrentUser().getUid(); DatabaseReference current_user_db = FirebaseDatabase.getInstance().getReference().child(“Users”).child(“Customers”).child(user_id); current_user_db.setValue(true); } } }); } }); mLogin.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { final String email = mEmail.getText().toString(); final String password = mPassword.getText().toString(); mAuth.signInWithEmailAndPassword(email, password).addOnCompleteListener(CustomerLoginActivity.this, new OnCompleteListener() { @Override public void onComplete(@NonNull Task task) { if(!task.isSuccessful()){ Toast.makeText(CustomerLoginActivity.this, “sign in error”, Toast.LENGTH_SHORT).show(); } } }); } }); } @Override protected void onStart() { super.onStart(); mAuth.addAuthStateListener(firebaseAuthListener); } @Override protected void onStop() { super.onStop(); mAuth.removeAuthStateListener(firebaseAuthListener); }}