title: How to get list of Firestore users by its uid?
body: <p>I have a method for get a List of users by its <code>uid</code>:</p>
  
  <pre><code>public void getNeededUsers(List&lt;String&gt; uidList, UsersListCallback usersListCallback) {
          CollectionReference users = db.collection(Consts.USERS_DB);
          for (String uid: uidList) {
              users.whereEqualTo(Consts.UID, uid).get()
                      .addOnCompleteListener(task -&gt; {
                          List&lt;FsUser&gt; fsUserList = new ArrayList&lt;&gt;();
                          for (DocumentSnapshot snapshot : task.getResult().getDocuments()) {
                              fsUserList.add(snapshot.toObject(FsUser.class));
                          }
                          usersListCallback.getUsers(fsUserList);
                      });
          }
      } 
  </code></pre>
  
  <p>But it seems that this method doesn`t work properly. When I try to iterate through the List of users in another method, I receive users one by one from callback, instead of getting all, so they are duplicated in my list.</p>
  
  <p>Here is a code of another method: </p>
  
  <pre><code>public void createUserChats(UserChatListCallback userChatListCallback) {
          final List&lt;UserChat&gt; userChatList = new ArrayList&lt;&gt;();
  
          getChatAndUidList((chatList, uidList) -&gt; {
              getRtUsersAndMessages(uidList, (rtUserList, messageList) -&gt; {
                  getNeededUsers(uidList, userList -&gt; {
  
                      if (!userList.isEmpty()) {
                          for (int i = 0; i &lt; userList.size(); i++) {
                              String name = userList.get(i).getName();
                              String image = userList.get(i).getImage();
                              String userId = userList.get(i).getUid();
  
                              long timeStamp = chatList.get(i).getTimeStamp();
                              boolean seen = chatList.get(i).getSeen();
  
                              String online = rtUserList.get(i).getOnline();
  
                              String message = messageList.get(i).getMessage();
                              long messageTimestamp = messageList.get(i).getTime();
  
  
                              userChatList.add(new UserChat(name, image, timeStamp, seen, userId, online,
                                      message, messageTimestamp));
  
                          }
                      }
                      userChatListCallback.getUserChatList(userChatList);
                  });
              });
          });
      }
  </code></pre>