0

I have a RecyclerView in my Android app and I have a FirestoreRecyclerAdapter that takes a model class (class name = Chat.kt)

Now in my Firestore, I have a document that holds an ArrayList of the above-said class.

I want to query and get that ArrayList of .

Firestore Screenshot

So basically I want that chat array to act as a collection and all the models inside that array as a document hope you understood.

can you suggest me a query

1 Answer 1

0

So basically I want that chat array to act as a collection.

That's simply not possible. FirestoreRecyclerOptions.Builder's setQuery() method, requires a Firestore Query as an argument. This means that the FirestoreRecyclerAdapter will render a view for each and every document that will be present in the result set. So there is no way you can pass a list of custom objects instead of a Query and act in the same way. What you can so, is to read the content of your chat array, and map each object into an object of your "Chat" class, as I have explained in one of my articles:

You'll lose the benefits of the Firebase-UI library but it will do the trick. So, unfortunately, you can't mix them together, it's one or the other.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.