Open rawandtakna opened 3 years ago
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.
@rawandtakna nice catch! I would suggest removing the if check from onStart and only keep addAuthStateListener(). Would you like to send a PR?
onStart
addAuthStateListener()
From the sample app, in the firestore chat app, here is the code in onStart() method
and in onAuthStateChanged
The method attachRecyclerViewAdapter() gets called twice every time the app is opened.