无法解析"updateUI" firebase [英] can not resolve 'updateUI' firebase

查看:77
本文介绍了无法解析"updateUI" firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Firebase使用电子邮件和密码对用户进行身份验证.但是它显示无法解析updateUI(user). 这是代码的这一部分.

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);
                            }
                        }
                    });
        }
    }
}

推荐答案

代码来自

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);
        }
    }

这篇关于无法解析"updateUI" firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆