title: query in firebase recyclerview adapter doesnt work
body: <p>I am trying trying to populate data in my firebase recyclerview using data from my firebase database.I am using the "query" functionality to filter the results but I am getting a null pointer exception error from the "query"  when i am running the app but the "query" is not returning "null" from debugging. This is my code</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
      setContentView(R.layout.users_list);
      users2 = (RecyclerView) findViewById(R.id.users_list);
      users2.setHasFixedSize(true);
      users2.setLayoutManager(new LinearLayoutManager(this));
  
  
      firebaseAuth = FirebaseAuth.getInstance();
  
          databaseReference = FirebaseDatabase.getInstance().getReference().child("Users");
  
      final String user_id = firebaseAuth.getCurrentUser().getUid();
  
  
  
      databaseReference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot){
  
              halls2 = (String) dataSnapshot.child("Male").child(user_id).child("halls").getValue();
              halls1 = (String) dataSnapshot.child("Female").child(user_id).child("halls").getValue();
  
              if(dataSnapshot.child("Male").hasChild(user_id)){
              }
              else{
                  query = databaseReference.child("Male").orderByChild("halls").equalTo(halls1);
              }
  
          }
          @Override
          public  void onCancelled(DatabaseError databaseError){
  
          }
      });
  
      databaseReference.addValueEventListener(new ValueEventListener() {
          @Override
          public void onDataChange(DataSnapshot dataSnapshot){
  
  
              if(dataSnapshot.child("Male").hasChild(user_id)){
  
                  query = databaseReference.child("Female").orderByChild("halls").equalTo(halls2);
  
  
              }
              else{
                  query = databaseReference.child("Male").orderByChild("halls").equalTo(halls1);
  
              }
  
  
  
          }
  
          @Override
          public  void onCancelled(DatabaseError databaseError){
  
          }
      });
  
      FirebaseRecyclerAdapter&lt;User, UserViewholder&gt; firebaseRecyclerAdapter = new FirebaseRecyclerAdapter&lt;User, UserViewholder&gt;(
              User.class, R.layout.users_row, UserViewholder.class, query) {
          @Override
          protected void populateViewHolder(UserViewholder viewHolder, User model, int position) {
              viewHolder.setUsername(model.getUsername());
              viewHolder.setLevels(model.getLevels());
              viewHolder.setDownloadUrl(getApplicationContext(), model.getDownloadUrl());
          }
  
      };
  
      users2.setAdapter(firebaseRecyclerAdapter);
  </code></pre>
  
  <p>DATABASE STRUCTURE</p>
  
  <pre><code>{
    "Users" : {
      "Female" : {
        "WwBjblOo8maSP5PXlYviONrS3Oo2" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2Fecf2758a-5628-4297-bcb3-e8c3f138cbbd.jpeg?alt=media&amp;token=1ca6067d-6c08-49b9-a2bf-6a8315ada067",
          "halls" : "Kwapong",
          "levels" : "300",
          "username" : "merylstre"
        },
        "X8c80zaY0kfT5KVoTFHbhPIEG9z2" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F51dc26a1-45e8-4897-9c2f-14caf8e79cc5.jpeg?alt=media&amp;token=90818c1e-167e-4799-bc29-b3fe52529cd2",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "hashcodef"
        }
      },
      "Male" : {
        "2EXejmHoMlWoKSDb5APvSt8do5e2" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F83ca18a0-63a5-477a-ab1e-b2732b3ebfa1.jpeg?alt=media&amp;token=b8626221-a67c-48e3-b958-d373c9f63c69",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "fillman"
        },
        "BW79oGosAIhdxDxYXbtHbSbC0D23" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F90b93b19-230b-4f28-b394-358d0c516c5c.jpeg?alt=media&amp;token=0c82c272-d6fb-46e8-a6cf-581f5501de7b",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "radjames"
        },
        "Mop4hbS0zne6QS3woum1udLgwqf1" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F78621a8b-7d67-413c-9e57-f378e60ba41e.jpeg?alt=media&amp;token=3982ee0a-2a34-41b3-9250-f0884531ee86",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "radjohn"
        },
        "VvnOY3k7Cwa36bJW55JiZDJRwPN2" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F1ac7080f-8db8-49a7-bb76-34b007deb839.jpeg?alt=media&amp;token=6d100527-80d3-49b3-b0ae-617dd55e64de",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "ciryadams"
        },
        "WOT11DVkoVb9owzK4qKHbvT4ODF2" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F3fda02ae-c577-4a4a-86c1-cadcaf518c97.jpeg?alt=media&amp;token=5baf2a79-b14c-4e28-b7bb-77e55ae08e55",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "markzuck"
        },
        "dbnmFoC4hnSCsXsxJgVO0Q7GYx13" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F2366c787-fb16-4049-9c7d-3d0c2a09ab9b.jpeg?alt=media&amp;token=25bda8dd-ab24-4b9b-8299-534e49bf9ed4",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "dasdsada"
        },
        "iqZfSgGNpPZ4HDtOUuHYZ1u8x273" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2Fc52cd467-05b9-4ece-8085-4cdf502839c5.jpeg?alt=media&amp;token=4c9eb36e-4644-49ec-85eb-c2fef38ca50e",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "maameEsi"
        },
        "jj9yycmDNbZwiPVTLrRyYZheM702" : {
          "downloadUrl" : "https://firebasestorage.googleapis.com/v0/b/loginapp-8088d.appspot.com/o/userProfiles%2F5c4a34b2-bc7b-43e7-8b00-7e0bf63ff252.jpeg?alt=media&amp;token=59a11905-a67d-48ea-9f16-10ffd3915876",
          "halls" : "Sarbah",
          "levels" : "100",
          "username" : "hashcode"
        }
      }
    }
  }
  </code></pre>
  
  <p>ERROR LOG</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                    Process: dev.mintz.loginapp, PID: 3157
                    java.lang.RuntimeException: Unable to start activity ComponentInfo{dev.mintz.loginapp/dev.mintz.loginapp.Users}: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.database.ChildEventListener com.google.firebase.database.Query.addChildEventListener(com.google.firebase.database.ChildEventListener)' on a null object reference
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2665)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726)
                        at android.app.ActivityThread.-wrap12(ActivityThread.java)
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477)
                        at android.os.Handler.dispatchMessage(Handler.java:102)
                        at android.os.Looper.loop(Looper.java:154)
                        at android.app.ActivityThread.main(ActivityThread.java:6119)
                        at java.lang.reflect.Method.invoke(Native Method)
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)
                     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'com.google.firebase.database.ChildEventListener com.google.firebase.database.Query.addChildEventListener(com.google.firebase.database.ChildEventListener)' on a null object reference
                        at com.firebase.ui.database.FirebaseArray.&lt;init&gt;(FirebaseArray.java:41)
                        at com.firebase.ui.database.FirebaseRecyclerAdapter.&lt;init&gt;(FirebaseRecyclerAdapter.java:91)
                        at dev.mintz.loginapp.Users$2.&lt;init&gt;(Users.java:0)
                        at dev.mintz.loginapp.Users.onCreate(Users.java:108)
                        at android.app.Activity.performCreate(Activity.java:6679)
                        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2618)
                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2726) 
                        at android.app.ActivityThread.-wrap12(ActivityThread.java) 
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1477) 
                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                        at android.os.Looper.loop(Looper.java:154) 
                        at android.app.ActivityThread.main(ActivityThread.java:6119) 
                        at java.lang.reflect.Method.invoke(Native Method) 
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886) 
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) 
  </code></pre>