When i upgrade my firebase-ui version to 3.2.2 the firebaserecycleradapter doesn\'t show any output the code of mine. at first when i got multidex error then i upgrade all libra
In order to make your code work, please consider using the following steps.
Remove the static
from the declaration of your UsersViewHolder
class. Should be only:
public class UsersViewHolder extends RecyclerView.ViewHolder {/* ... */}
Remove the static
keyword also from the mView
field and all your methods. Your holder class should look like this:
public class UsersViewHolder extends RecyclerView.ViewHolder {
private View mView;
private CircleImageView mUserView;
public UsersViewHolder(View itemView) {
super(itemView);
mView = itemView;
}
public void setName(String name){
TextView userNameView = (TextView) mView.findViewById(R.id.user_single_name);
userNameView.setText(name);
}
public void setStatus(String status){
TextView userStatusView = (TextView) mView.findViewById(R.id.user_single_status);
userStatusView.setText(status);
}
public void setRIDNo(String ridno){
TextView userRIDNoView = (TextView) mView.findViewById(R.id.user_single_ridno);
userRIDNoView.setText(ridno);
}
public void setUserImage(String thumb_image, Context ctx){
CircleImageView userImageView = (CircleImageView) mView.findViewById(R.id.user_single_image);
Picasso.with(ctx).load(thumb_image).placeholder(R.drawable.default_avatar).into(userImageView);
}
}
Move all the code from the onStart()
method inside onCreate() method except this line of code:
super.onStart();
Make your firebaseRecyclerAdapter
varaible global:
private FirebaseRecyclerAdapter firebaseRecyclerAdapter;
Remove FirebaseRecyclerAdapter
from the onCreate() method.
Add the following lines of code in the onStart()
and onStop()
methods.
@Override
protected void onStart() {
super.onStart();
firebaseRecyclerAdapter.startListening();
}
@Override
protected void onStop() {
super.onStop();
if(firebaseRecyclerAdapter != null) {
firebaseRecyclerAdapter.stopListening();
}
}
If you are using authentication, please also don't forget to add this line of code inside onStart()
method:
firebaseAuth.addAuthStateListener(authStateListener);