title: Retrieve a hashmap from firebase to populate FirebaseRecycler, null HashMap
body: <p>I am trying to retrieve a HashMap from Firebase to populate my Firebase <code>RecyclerView</code> below is my model class that I am trying to retrieve:</p>
  
  <pre><code>public class Employee{
  private HashMap&lt;String, Person&gt; PeopleMap; 
  // =  new HashMap&lt;String, Person&gt;();
  
  public Employee () {
  }
  
  public Employee(HashMap&lt;String, Person&gt; people) {
      this.PeopleMap= people;
  }
  
  public HashMap&lt;String, Person&gt; getMap() {
      return PeopleMap;
  }
  public void setMap(HashMap&lt;String, Person&gt; people) {
      this.PeopleMap= people;
  }
  }
  </code></pre>
  
  <p>Person class</p>
  
  <pre><code>public class Person {
  private String ImageUrl;
  private  String Name;
  private String  Pay;
  public Person() {
  }
  
  public Person(String name, String imageUrl, String pay, 
   ) {
      ImageUrl = imageUrl;
      Name = name;
      Pay = pay;
  
  }
  
  public String getImageUrl() {
      return ImageUrl;
  }
  
  public void setImageUrl(String imageUrl) {
      ImageUrl = imageUrl;
  }
  
  public String getName() {
      return Name;
  }
  
  public void setName(String name) {
      Name = name;
  }
  
  public String getPay() {
      return Pay;
  }
  
  public void setPrice(String pay) {
      Pay= pay;
  }
  }
  </code></pre>
  
  <p>Now the problem is that when i retrieve my Employe model class in firebase recycler it is not null but if i retrieve my Hashmap from there the size of map is zero while there are items on the map below is what i am doing </p>
  
  <p>Firebase REycler </p>
  
  <pre><code>        @Override
          protected void onBindViewHolder( ConvoViewHolder holder,  int 
          position,  Employee model) {
              if (model.equals(null)){
                  Toast.makeText(OrderConversation.this, "object is null", 
                  Toast.LENGTH_SHORT).show();
              }
              else
              {
                  HashMap&lt;String, OrderItem&gt; cartitems =  model.getCart();
                  int i = cartitems.size();
               if (i==0)
                      {
                          Toast.makeText(OrderConversation.this, "null 
                          map", Toast.LENGTH_SHORT).show();
                      }
                      else {
                          Toast.makeText(OrderConversation.this, "size of 
                          map in bind"+ Integer.toString(i),
                          Toast.LENGTH_SHORT).show();
                      }
              }
          }
      };
      mEmpList.setAdapter(adapter);
      adapter.startListening();
  </code></pre>
  
  <p>My Database structure is like below with employee as a parent node and </p>
  
  <p><a href="https://i.stack.imgur.com/4yHEV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4yHEV.jpg" alt="enter image description here"></a>    </p>
  
  <p>Sorry I had to type it i hope it is clear to everyone about what kind of str i have. i want to retrieve from department node so that i can get two object (DHead1 &amp; Dhead2 ),  which have different no of elements in them as Dhead has 3 objects of person class and Dhead2 has 2. so one way i can go is either i load them first into a list and them use them or the other way that i am using now i.e. retrieve them as an object which contains the map of person class object.</p>
  
  <p>i tried this below and i am getting values fine but inside onbindview its not working</p>
  
  <pre><code>mDatabase.addValueEventListener(new ValueEventListener() {
               @Override
               public void onDataChange(DataSnapshot dataSnapshot) {
                   for(DataSnapshot ds: dataSnapshot.getChildren()){
                       GenericTypeIndicator&lt;Map&lt;String, Person&gt;&gt; to = new 
                       GenericTypeIndicator&lt;Map&lt;String, Person&gt;&gt;() {};
                       Map&lt;String, Person&gt; map = ds.getValue(to);
                       for(Person ml:convoModels.values()) {
                           String name = ml.getName();
                           Toast.makeText(context, "name is "+ name, 
                           Toast.LENGTH_SHORT).show();
                       }
                     }
                }
               @Override
               public void onCancelled(DatabaseError databaseError) {
               }
           });
  </code></pre>