Skip to content

Error in the sample app or a coding practice #1997

@rawandtakna

Description

@rawandtakna

From the sample app, in the firestore chat app, here is the code in onStart() method

public void **onStart**() {
    super.onStart();
    if (isSignedIn()) {
        **attachRecyclerViewAdapter**();
    }
    FirebaseAuth.getInstance().addAuthStateListener(this);
}

and in onAuthStateChanged

@Override
public void **onAuthStateChanged**(@NonNull FirebaseAuth auth) {
    mBinding.sendButton.setEnabled(isSignedIn());
    mBinding.messageEdit.setEnabled(isSignedIn());

    if (isSignedIn()) {
        **attachRecyclerViewAdapter**();
    } else {
        Toast.makeText(this, R.string.signing_in, Toast.LENGTH_SHORT).show();
        auth.signInAnonymously().addOnCompleteListener(new SignInResultNotifier(this));
    }
}

The method attachRecyclerViewAdapter() gets called twice every time the app is opened.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions