title: Recycler view with Firebase data only loads when scrolling
body: <p>I am working with <code>Firebase</code> and using a <code>android.support.v7.widget.RecyclerView</code>. The issue is that <code>onStart</code> the view loads empty and the data is filled only after scrolling. Any idea why ?</p>
  
  <p><strong>Code</strong> : </p>
  
  <p><strong>RecyclerView</strong> (I am setting an empty adapter onStart to avoid "RecyclerView: No adapter attached; skipping layout" ) :</p>
  
  <pre><code> mLayoutManager = new LinearLayoutManager(getActivity());
   mLayoutManager.setReverseLayout(true);
   mLayoutManager.setStackFromEnd(true);
   mRecyclerView.setLayoutManager(mLayoutManager);
   mRecyclerView.setHasFixedSize(true);
  
   mRecyclerView.getRecycledViewPool().setMaxRecycledViews(1,0);                                     
   mRecyclerView.setAdapter(new RecyclerView.Adapter() {
          @Override
          public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
              return null;
          }
  
          @Override
          public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
  
          }
  
          @Override
          public int getItemCount() {
              return 0;
          }
      });
  </code></pre>
  
  <p><strong>Firebase data fetch:</strong></p>
  
  <pre><code>databaseReference.child("/News").orderByChild("createdAt").addValueEventListener(new ValueEventListener() {
      @Override
      public void onDataChange(final DataSnapshot dataSnapshot) {
  
          for (DataSnapshot postSnapshot : dataSnapshot.getChildren()) {
  
              final News news = postSnapshot.getValue(News.class);
              final PostListClass postListClass = new PostListClass();
              //add fac id admin
              if (news.getFaculteId().equals(userFaculteId) || news.getFaculteId().equals("Admin")) {
                  postListClass.setPostId(postSnapshot.getKey());
                  postListClass.setPostTitle(news.getHeadlines());
                  postListClass.setPostDescription(news.getDetails());
  
                  databaseReference.child("/users").child(news.getAuthor()).addListenerForSingleValueEvent(new ValueEventListener() {
                      @Override
                      public void onDataChange(DataSnapshot usersSnapShot) {
                          User user = usersSnapShot.getValue(User.class);
  
                          postListClass.setPostOwnerId(usersSnapShot.getKey());
                          postListClass.setPostOwnerName(user.getPrenom() + " " + user.getNom());
                          postListClass.setPostOwnerPromo(user.getPromotion());
  
                          try {
                              Calendar cal = Calendar.getInstance(Locale.ENGLISH);
                              cal.setTimeInMillis(news.getCreatedAt() * 1000);
                              SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
                              Date date = sdf.parse(DateFormat.format("dd-MM-yyyy", cal).toString());
                              String day = (String) android.text.format.DateFormat.format("dd", date);
                              String month = (String) android.text.format.DateFormat.format("MMM", date);
                              postListClass.setPostDate(day + " " + month);
                          } catch (java.text.ParseException e) {
                              e.printStackTrace();
                          }
                          storageRef.child("users/" + news.getAuthor() + ".jpg").getDownloadUrl().addOnSuccessListener(new OnSuccessListener&lt;Uri&gt;() {
                              @Override
                              public void onSuccess(Uri uri) {
                                  postListClass.setPostOwnerImageUrl(String.valueOf(uri));
                              }
                          }).addOnFailureListener(new OnFailureListener() {
                              @Override
                              public void onFailure(@NonNull Exception exception) {
                                  // Handle any errors
  
                                  if (exception.getClass().isInstance(StorageException.class)) {
                                      postListClass.setPostOwnerImageUrl("NullImage");
  
                                  }
  
                              }
                          });
  
                      }
  
                      @Override
                      public void onCancelled(DatabaseError databaseError) {
                      }
                  });
  
                  databaseReference.child("/News").child(postSnapshot.getKey()).child("/Comments").addValueEventListener(new ValueEventListener() {
                      @Override
                      public void onDataChange(DataSnapshot dataSnapshot) {
                          postListClass.setPostComments(String.valueOf(dataSnapshot.getChildrenCount()));
  
                      }
  
                      @Override
                      public void onCancelled(DatabaseError databaseError) {
  
                      }
                  });
  
                  storageRef.child("News/" + postSnapshot.getKey() + ".png").getDownloadUrl().addOnSuccessListener(new OnSuccessListener&lt;Uri&gt;() {
                      @Override
                      public void onSuccess(Uri uri) {
                          postListClass.setPostImageUrl(String.valueOf(uri));
  
                      }
                  }).addOnFailureListener(new OnFailureListener() {
                      @Override
                      public void onFailure(@NonNull Exception exception) {
  
                          postListClass.setPostImageUrl("NullImage");
  
                      }
                  });
  
                  postListClasses.add(postListClass);
  
  
              }
  
          }
  
         postsAdapter = new PostsAdapter(getContext(), postListClasses);
          mRecyclerView.setAdapter(postsAdapter);
  
      }
  
  
      @Override
      public void onCancelled(DatabaseError databaseError) {
  
      }
  });
  </code></pre>
  
  <p><strong>So this is the result when the app starts (Three fields are missing data) :</strong></p>
  
  <p><a href="https://i.stack.imgur.com/CDLyDl.png" rel="nofollow"><img src="https://i.stack.imgur.com/CDLyDl.png" alt="enter image description here"></a></p>
  
  <p><strong>And After Scrolling (Missing data gets filled) :</strong> </p>
  
  <p><a href="https://i.stack.imgur.com/9qhDll.png" rel="nofollow"><img src="https://i.stack.imgur.com/9qhDll.png" alt="enter image description here"></a></p>