How can we achieve grouping of documents based on dates using FirestoreRecyclerAdapter in Android

Viewed 35

How can we achieve grouping of documents based on dates using FirestoreRecyclerAdapter?

Like below:

20th Nov 2021 -item 21sth Nov 2021 -item -item -item 22nd Nov 2021 -item -item

1 Answers

The Firestore adapters in the FirebaseUI library display a simple, flat list of documents based on the query that you pass in, rendering one view holder for each document.

They have very limited support for varying the layout for each document, basically only allowing you to select a different view holder based on information in the document. There is no support for adding additional view holders for items that are not being returned from Firestore, like the date groupings in your use-case.

You will need to build your own adapter to allow this sort of layout.

Related