I am using Firebase. My problem is, while i'm querying objects and then modifying them, my main ui thread goes ahead and runs the next methods. I want my main ui thread to wait until my firebase query is finished and I made all the necessary changes in onDataChange AND THEN continue to run my other functions i written.
Currently, I just imported the external library "Otto" but im not sure how to use it and I was hoping someone can help guide me.
                Firebase cardReference = mRef.child("reference");
                cardReference.addValueEventListener(new ValueEventListener() {
                    @Override
                    public void onDataChange(DataSnapshot dataSnapshot) {
                    //DO STUFF
                    }
                    @Override
                    public void onCancelled(FirebaseError firebaseError) {
                    }
                });
               //Once STUFF is done, run nextMethod()
               nextMethod();
        }
 
     
    