Search code examples
androidfirebasefirebase-realtime-databasefirebaseui

FirebaseRecyclerAdapter with 2 children


I have this database:

Database:
   X:{
     UserID:{
        UNIQUE_ID_GENERATED_BY_PUSH_METHOD:{
          x:"hello",
          y:"hey there!"
       }
        UNIQUE_ID_2_GENERATED_BY_PUSH_METHOD:{
          x:"what's up?",
          y:"Nothing Much"
       }
   }  
    UserID2:{
        UNIQUE_ID_GENERATED_BY_PUSH_METHOD:{
          x:"bye",
          y:"Have a nice day!"
       }
        UNIQUE_ID_2_GENERATED_BY_PUSH_METHOD:{
          x:"what's up?",
          y:"Nothing Much"
       }
   }  
}

However, my FirebaseRecyclerAdapter is empty with this database as I pass this DatabaseReference to my FirebaseRecyclerAdapter:

DatabaseReference = FirebaseDatabase.getInstance().getReference().child("X");
mAdapter = new FirebaseRecyclerAdapter<Campaign, CampaignHolder>(Campaign.class, R.layout.recyclerview_template, CampaignHolder.class, ref) {
//...
}

It works fine when I don't have each post under the user's userID. So if I remove the parent UserID, my FirebaseRecyclerAdapter won't be empty.

How can I fix this problem?


Solution

  • Flattening nested data is not currently a feature of FirebaseUI. If you think there is common demand for it, file a feature request on the Github repo. I haven't seen this request before though, so you might be better off building this on your own fork of the repo.