I'm trying to get different subcollections and adapt them to my RecyclerAdapter
with Firebase-UI.
My Cloud Firestore is set like this:
user:(Collection)
uid1:(Document)
name, email(fields)
data:(Collection)
uid1:(Document)
images:(Collection)
document1
fields
pdf:(Collection)
document1
fields
So I was thinking and I don't know how to query different Collections with the same model and adapt them into the recycler adapter.
My actual code can retrieve images:
private void setupImages(){
Query query = fStore.collection("data").document(userID).collection("images"); //get images collection
FirestoreRecyclerOptions<Data> options = new FirestoreRecyclerOptions.Builder<Data>().setQuery(query,Data.class).build();
FirestoreRecyclerAdapter adapter = new ImageAdapter(options, getContext());
recyclerView.setLayoutManager(new GridLayoutManager(getContext(), 2));
recyclerView.setAdapter(adapter); //adapt the query to adapter
}
And the class binds the data to the view with the Data model.
I've thought about creating a list and adding the items, but I don't think it's a good way and there should be other options.
Question: How can I bind different collections into the recycler adapter without being replaced?
PS: Feel free to comment in any way to improve my database. I'm new!