Query 4 Firebase Realtime DB nodes asynchronously and then transform the data in Android Java app

20 hours ago 1
ARTICLE AD BOX

Here is my dilemma, I need to query ALL 4 nodes in Firebase Realtime DB in an Android Java app (I have this working fine in iOS):

PlayerInGroup

Users

PlayerPicks

Teams

I start by getting the Player Count (PlayerInGroup node).

For each player; I retrieve the players username (Users node; as that is what will be displayed for the view of the players picks)

Followed by the Players Picks (PlayerPicks node)

Which lastly I will need to get the Team Info (Teams node) so that I can display the team logo and name in the view as well.

I am utilizing interface Callback as seen below:

private interface PlayerPicksCallback { void onComplete(DataSnapshot dataSnapshot); void onNoResult(); void onStart(); void onFailure(); }

Which works and it gets me the data....

BUT here is the thing, the data can be different from one user to the next where it seems the picks per users are "shifted" and it doesn't seem to constantly return the data the same for all the user like i am able to achieve in iOS using completion handlers... which by the way stresses me out that Android does NOT have the same completion handler technology else this would be an non issue.

Can anyone who may have dealt with this usecase, which I would imagine this is a common usecase, how did you solve for this !?

How do i get all the data consistently and then transform it consistently by "merging" it based on the logic mentioned above?

Read Entire Article