View ProgressBar when logging in to Firebase

0

When I log in, I want a loading bar to appear while the login is being done. How do I get the process (time, size ...) of Firebase to be able to increment in the progress bar?

Here is the login code:

private void efetuarLogin() {
    final FirebaseAuth autenticacaoFirebase = ConfiguracaoFirebase.getFirebaseAuth();
    autenticacaoFirebase.signInWithEmailAndPassword(
            usuario.getEmail(),
            usuario.getSenha()
    ).addOnCompleteListener(new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            if (task.isSuccessful()) {
             //   FirebaseUser firebaseUser = autenticacaoFirebase.getCurrentUser();
                telaPrincipal();
            } else {
                String erroExcecao = "";
                try {
                    throw task.getException();
                } catch (FirebaseAuthInvalidCredentialsException e) {
                    erroExcecao = "E-mail inválido e/ou senha incorreta";
                    MetodosAuxiliares.Alert(LoginActivity.this, erroExcecao);
                } catch (Exception e) {
                    e.printStackTrace();
                    MetodosAuxiliares.Alert(LoginActivity.this, "Verifique seu e-mail e/ou senha");
                }
            }
        }
    });

}
    
asked by anonymous 09.06.2018 / 03:42

1 answer

0

In the first line of the efetuarLogin() method add:

final ProgressDialog dialog = ProgressDialog.show(this, "Titulo", "Texto", true);

Then, within your onComplete() add:

dialog.dismiss();
    
09.06.2018 / 17:40