2

I need to use Collections.shuffle() at the recyclerView , But it is not possible because I use firebase query :

 query=FirebaseDatabase.getInstance().getReference("Videos").orderByChild("s").equalTo("1");

so Collections.shuffle((List<?>) query2); will show an error

Also I tried to user startAt() inside query but I could't detect the key and value of child s in the same query.

so please help me with any solutions or alternatives

Leenah
  • 850
  • 3
  • 15
  • 36
  • You can take a look [here](https://stackoverflow.com/questions/48245706/how-can-i-retrieve-a-random-value-firebase-database/48248306); – Alex Mamo May 07 '18 at 10:09
  • @AlexMamo Thank you, Could you please let me know how can I use it with firebase query? – Leenah May 07 '18 at 10:19
  • You want to pass a random number to a query? – Alex Mamo May 07 '18 at 10:22
  • I need to get all children which includes child `s == 1` and detect the key of random child to use in startAt() – Leenah May 07 '18 at 10:28
  • Please add your database structure and indicate through a concrete example. – Alex Mamo May 07 '18 at 10:32
  • Thank you for your support, I realized that it is not possible to use`child(x).equles(x)` and `orderbyKey().startAt()` in the same query so I've change my database structure to make a specific query for each section then sorted by `startAt(randomValue)` – Leenah May 07 '18 at 20:59
  • That's good. Cheers! – Alex Mamo May 08 '18 at 06:27

0 Answers0