My structure
So I have an app in which users upload posts in my adapter. I can retrieve the post description and the post picture, but when I try to retriev
Its better to not include any firebase calls inside your ViewBinder for recycler view. What you can do is update your BlogPost and include a field name with getter and setter. Then inside your activity where you are adding the BlogPost to the recycler adapter you can fetch the user name add the name to the blog post and notify adapter of data change.
In your activity do this
// adding BlogPost to list
// Create BlogPost object with the data.
blogList.add(blogPostObject)
firebaseDatabase.child("Users").child(user_id).child("name").addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
if(dataSnapshot.exists()){
blogPostObject.setName(dataSnapshot.getValue().toString());
adapter..notifyItemChanged(indexOfblogPostObject);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});