Basically, what I am trying to do is use a FirebaseRecyclerAdapter
and populate the RecyclerView
with my custom designed CardView
. The
In order to be able to display data from the Firebase realtime database you need to start listening for changes and for that you should add the following line of code in the onStart()
method:
@Override
protected void onStart() {
super.onStart();
FBRA.startListening();
}
To stop listening foir changes you need add the following line of code in the onStop()
method like this:
@Override
protected void onStop() {
super.onStop();
if(FBRA != null) {
FBRA.stopListening();
}
}
Please see my answer from this post where I have explained why you should remove the listener.
P.S. Please also don't forget to make the FBRA
a global variable and remove FirebaseRecyclerAdapter<ServiceClass, ServiceViewHolder>
from the declaration of the object.
This is more of an advice. If you want to continue using the old method to populate your recyclerview ie The "populateViewHolder" method instead of the new "onBindViewHolder" method just use this;
implementation 'com.firebaseui:firebase-ui:1.0.1'
instead of upgraded firebase-ui versions