0

I have a list of math topics as documents in firebaseFirestore. The objects of these topics (documents) have a field called, rootTopic that can be used to categorize them into groups.

enter image description here

I would like to query the collection of these topics (documents) and display them in groups using a recyclerView-in-recyclerView as seen below

enter image description here

THE CHALLENGE IS:

I am not quite sure how best to dynamically query and group these topics(documents). Please assist with hints or snippets on how to achieve this.

Eric
  • 37
  • 1
  • 7

2 Answers2

1

There are two ways to query the data you want:

  1. Make a query of the whole collection and group the results by the rootTopic field. Note that you'll need to partition the returned data, the data will just be ordered.
db.collection("Mathematics").orderBy("topicName")
// Then partition the results and render them.
  1. Somehow get the list of different topicRoot and make a query for each of them by applying an equality filter. Here no need for partitioning code wise but several queries would be needed.

In any case I would suggest reading the documentation on queries and sorting cause it's pretty well explained there.

Happy-Monad
  • 1,962
  • 1
  • 6
  • 13
0

You should use multiple view types in a single recyclerView instead of multiple recyclerView. Here is one example article about it.

Mustafa Kuloğlu
  • 1,122
  • 1
  • 8
  • 16
  • Thanks, @Mustafa, but what I need is simply a way to query firestore and group the received data in recyclerView using the rootTopic as stated in the problem – Eric Dec 17 '20 at 01:20