title: Firebase Android onDataChange will not call
body: <p>What I'm trying to do is get a list of user IDs from Firebase, then get the data from each of those users. The issue I'm having is that while I can quite happily retrieve the list of IDs, it doesn't seem to work - the <code>onDataChange</code> for this query is never reached.</p>
  
  <p>I have tried amending the code within <code>configurePage</code> by removing the for loop and even hardcoding a value for ID, but no matter what I do nothing is ever added to <code>listOfItems</code> and you still cannot reach <code>onDataChange</code>. The log line in <code>configurePage</code> shows the correct number of IDs, so I can rule out the first query not finishing in time for the second to start.</p>
  
  <p>First query:</p>
  
  <pre><code>public void getIDs() {
      spinner.setVisibility(View.VISIBLE);
      search = mDatabase.child("linked_users").child(userID);
      val = new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot) {
              Log.d(TAG, "Test:" + dataSnapshot.getChildrenCount());
              for (DataSnapshot singleChild : dataSnapshot.getChildren()) {
                  listOfIDs.add(singleChild.getKey());
              }
              if (listOfIDs.size() == 0) {
                  spinner.setVisibility(View.GONE);
                  noResultsLabel.setVisibility(View.VISIBLE);
                  countLabel.setVisibility(View.GONE);
              } else {
                  countLabel.setText("Total users: " + listOfIDs.size());
                  countLabel.setVisibility(View.VISIBLE);
                  configurePage();
              }
          }
  
          @Override
          public void onCancelled(DatabaseError databaseError) {
              Log.d(TAG, "DB problem");
              AlertDialog.Builder dialog = new AlertDialog.Builder(AgentViewUsers.this);
              dialog = databaseDialog(dialog);
              dialog.show();
          }
      };
      search.addListenerForSingleValueEvent(val);
  }
  </code></pre>
  
  <p>Second query:</p>
  
  <pre><code>public void configurePage() {
      Log.d(TAG, "test = " + listOfIDs.size());
      for (String id : listOfIDs){
          mDatabase.child("users").child(id).addListenerForSingleValueEvent(new ValueEventListener() {
              @Override
              public void onDataChange(DataSnapshot dataSnapshot) {
  
                  AgentUserViewObject obj = new AgentUserViewObject();
                  obj.name = dataSnapshot.child("full_name").getValue().toString();
                  obj.address = dataSnapshot.child("address").getValue().toString() + ", " + dataSnapshot.child("towncounty").getValue().toString() + ", " + dataSnapshot.child("postcode").getValue().toString();
                  obj.requestCount = Integer.parseInt(dataSnapshot.child("requests_submitted").getValue().toString());
                  listOfItems.add(obj);
              }
  
              @Override
              public void onCancelled(DatabaseError databaseError) {
  
              }
          });
      }
      mLayoutManager = new LinearLayoutManager(AgentViewUsers.this);
      mAdapter = new AgentUserViewAdapter(listOfItems);
      mRecyclerView.addItemDecoration(new DividerItemDecoration(AgentViewUsers.this,DividerItemDecoration.VERTICAL_LIST));
      mRecyclerView.setLayoutManager(mLayoutManager);
      mRecyclerView.setAdapter(mAdapter);
      spinner.setVisibility(View.GONE);
  }
  </code></pre>