title: How to properly access the names of documents in firestore to populate a RecyclerView?
body: <p>Following <a href="https://stackoverflow.com/questions/46979375/firestore-how-to-structure-a-feed-and-follow-system">this</a> I am trying to fill my <code>RecyclerView</code> with posts from my Firestore. </p>
  
  <p>My Firestore is structured exactly the same as in the linked answer so I am trying to replicate it. I think my issue is that I am not accessing the name of the documents properly. Would I have to use a <code>.get()</code> to retrieve the name? Below is what I have:</p>
  
  <pre class="lang-java prettyprint-override"><code>private CollectionReference userFollowingReference = rootRef.collection("following/"+ currentUser.getUid()+"/UserIsFollowing");
  </code></pre>
  
  <pre><code>Query first = rootRef.collection("posts/"+ userFollowingReference.getId()+"/userPosts")
                  .orderBy("date", Query.Direction.DESCENDING)
                  .limit(3);
          first.get().addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
              @Override
              public void onComplete(@NonNull final Task&lt;QuerySnapshot&gt; task) {
                  if (task.isSuccessful()) {
                      for (DocumentSnapshot document : task.getResult()) {
                          Post post = document.toObject(Post.class);
                          list.add(post);
                      }
                      followerAdapter.notifyDataSetChanged();
  
                      RecyclerView.OnScrollListener onScrollListener = new RecyclerView.OnScrollListener() {
                          @Override
                          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                              super.onScrollStateChanged(recyclerView, newState);
                              if (newState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
                                  isScrolling = true;
                              }
                          }
  
                          @Override
                          public void onScrolled(RecyclerView recyclerView, int dx, int dy) {
                              super.onScrolled(recyclerView, dx, dy);
                              lastVisible = task.getResult().getDocuments().get(task.getResult().size() - 1);
                              LinearLayoutManager linearLayoutManager = ((LinearLayoutManager) recyclerView.getLayoutManager());
                              int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
                              int visibleItemCount = linearLayoutManager.getChildCount();
                              int totalItemCount = linearLayoutManager.getItemCount();
  
                              if (isScrolling &amp;&amp; (firstVisibleItemPosition + visibleItemCount == totalItemCount) &amp;&amp; !isLastItemReached) {
                                  isScrolling = false;
                                  Query nextQuery = userFollowingReference.startAfter(lastVisible).limit(3);
                                  nextQuery.get().addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
                                      @Override
                                      public void onComplete(@NonNull Task&lt;QuerySnapshot&gt; t) {
                                          if (t.isSuccessful()) {
                                              for (DocumentSnapshot d : t.getResult()) {
                                                  Post post = d.toObject(Post.class);
                                                  list.add(post);
                                              }
                                              followerAdapter.notifyDataSetChanged();
                                              lastVisible = t.getResult().getDocuments().get(t.getResult().size() - 1);
  
                                              if (t.getResult().size() &lt; 3) {
                                                  isLastItemReached = true;
                                              }
                                          }
                                      }
                                  });
                              }
                          }
                      };
                      recyclerView.addOnScrollListener(onScrollListener);
                  }
              }
          });
  </code></pre>
  
  <p>It should out put posts from all of the users that the current user is following but my output is blank</p>
  
  <p><strong>Edit:</strong>
  Here is a screenshot of my DB:
  <a href="https://i.stack.imgur.com/zVfbc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zVfbc.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/t8r1r.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/t8r1r.png" alt="enter image description here"></a>
  The sub collection <code>UserIsFollowing</code> contains documents named after the users that the user is following whose only field is a boolean Set to true.</p>
  
  <p><strong>Edit 2:</strong></p>
  
  <p>I changed the code so that I first retrieve the list of followers then use that list to get their posts but this is still not working:</p>
  
  <pre><code>Query first = userFollowingReference;//TODO Realtime updates
          first.get().addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
              @Override
              public void onComplete(@NonNull final Task&lt;QuerySnapshot&gt; task) {
                  if (task.isSuccessful()) {
                      for (DocumentSnapshot document : task.getResult()) {
                          String id = document.getId();
                          followingList.add(id);
                      }
                      followerAdapter.notifyDataSetChanged();
                      if(!followingList.isEmpty()) {
                          Query second = rootRef.collection("posts/" + followingList.get(0) + "/userPosts")
                                  .orderBy("date", Query.Direction.ASCENDING)
                                  .limit(3);
                          second.get().addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
                              @Override
                              public void onComplete(@NonNull final Task&lt;QuerySnapshot&gt; task) {
                                  if(task.isSuccessful()) {
                                      List&lt;Post&gt; list = new ArrayList&lt;&gt;();
                                      for(DocumentSnapshot document : task.getResult()){
                                          Post post = document.toObject(Post.class);
                                          list.add(post);
                                      }
                                      recyclerView.setAdapter(followerAdapter);
                                      followerAdapter.notifyDataSetChanged();
                                      lastVisible = task.getResult().getDocuments().get(task.getResult().size() - 1);
  
                                      RecyclerView.OnScrollListener onScrollListener = new RecyclerView.OnScrollListener() {
                                          @Override
                                          public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
                                              super.onScrollStateChanged(recyclerView, newState);
                                              if (newState == AbsListView.OnScrollListener.SCROLL_STATE_TOUCH_SCROLL) {
                                                  isScrolling = true;
                                              }
                                          }
  
                                          @Override
                                          public void onScrolled(final RecyclerView recyclerView, int dx, int dy) {
                                              super.onScrolled(recyclerView, dx, dy);
                                              lastVisible = task.getResult().getDocuments().get(task.getResult().size() - 1);
                                              int firstVisibleItemPosition = linearLayoutManager.findFirstVisibleItemPosition();
                                              int visibleItemCount = linearLayoutManager.getChildCount();
                                              int totalItemCount = linearLayoutManager.getItemCount();
  
                                              if (isScrolling &amp;&amp; (firstVisibleItemPosition + visibleItemCount == totalItemCount) &amp;&amp; !isLastItemReached) {
                                                  isScrolling = false;
                                                  Query nextQuery = rootRef.collection("posts")
                                                          .orderBy("date", Query.Direction.ASCENDING)
                                                          .startAfter(lastVisible).limit(3);
                                                  nextQuery.get().addOnCompleteListener(new OnCompleteListener&lt;QuerySnapshot&gt;() {
                                                      @Override
                                                      public void onComplete(@NonNull Task&lt;QuerySnapshot&gt; t) {
                                                          if (t.isSuccessful()) {
                                                              for (DocumentSnapshot d : t.getResult()) {
                                                                  Post post = d.toObject(Post.class);
                                                                  postList.add(post);
                                                              }
                                                              followerAdapter.notifyDataSetChanged();
                                                              lastVisible = task.getResult().getDocuments().get(task.getResult().size() - 1);
  
                                                              if (t.getResult().size() &lt; 3) {
                                                                  isLastItemReached = true;
                                                              }
                                                          }
                                                      }
                                                  });
                                              }
                                          }
                                      };
  
                                      recyclerView.addOnScrollListener(onScrollListener);
                                  }
  
                              }
                          });
                      }
                  }
              }
          });
  </code></pre>
  
  <p><strong>Edit 3:</strong></p>
  
  <p>I am getting this error:</p>
  
  <pre><code>E/RecyclerView: No adapter attached; skipping layout
      No adapter attached; skipping layout
  </code></pre>