Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

can not resolve 'updateUI' firebase

I am trying to authenticate users with email and password through firebase. But it shows can not resolve updateUI(user). Here's this part of the code.

public void OnContinue(View view) {
    if(hasClickedCountinueOnce){
        EditText emailTextBox = (EditText)findViewById(R.id.email);
        String user = userNAAME.getText().toString();
        String passwordText = password.getText().toString();
        String email = emailTextBox.getText().toString();
        //todo manage new account here
        if(!user.isEmpty() && !passwordText.isEmpty() ){
            mAuth.createUserWithEmailAndPassword(email, passwordText)
                    .addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
                        @Override
                        public void onComplete(@NonNull Task<AuthResult> task) {
                            if (task.isSuccessful()) {
                                // Sign in success, update UI with the signed-in user's information
                                Log.d("SignInFailed", "createUserWithEmail:success");
                                FirebaseUser user = mAuth.getCurrentUser();
                                updateUI(user);
                            } else {
                                // If sign in fails, display a message to the user.
                                Log.w("SignInFailed", "createUserWithEmail:failure", task.getException());
                                Toast.makeText(SignUP.this, "Authentication failed.",
                                        Toast.LENGTH_SHORT).show();
                                updateUI(null);
                            }
                        }
                    });
        }
    }
}
like image 563
Chirag Kalra Avatar asked Jun 12 '17 04:06

Chirag Kalra


2 Answers

If I am getting your problem rightly with the limited code that u shared above, the function call "updateUI" refred here (https://firebase.google.com/docs/auth/android/password-auth) is the call/function you have to write on your own to update ur UI elements, and as @BobSnyder mentioned here's the link to a reference code (https://github.com/firebase/quickstart-android/blob/master/auth/app/src/main/java/com/google/firebase/quickstart/auth/EmailPasswordActivity.java#L209)

like image 32
Scorpion_Abhi Avatar answered Sep 21 '22 06:09

Scorpion_Abhi


The code is from the Firebase Quickstart-Android project. This is what it does. You can implement something similar:

   private void updateUI(FirebaseUser user) {
        hideProgressDialog();
        if (user != null) {
            mStatusTextView.setText(getString(R.string.google_status_fmt, user.getEmail()));
            mDetailTextView.setText(getString(R.string.firebase_status_fmt, user.getUid()));

            findViewById(R.id.sign_in_button).setVisibility(View.GONE);
            findViewById(R.id.sign_out_and_disconnect).setVisibility(View.VISIBLE);
        } else {
            mStatusTextView.setText(R.string.signed_out);
            mDetailTextView.setText(null);

            findViewById(R.id.sign_in_button).setVisibility(View.VISIBLE);
            findViewById(R.id.sign_out_and_disconnect).setVisibility(View.GONE);
        }
    }
like image 94
Bob Snyder Avatar answered Sep 18 '22 06:09

Bob Snyder