0

So using GeoFire I was able to put all the keys returned into a List.

 ArrayList<String> arrayList = new ArrayList();

    GeoQuery geoQuery = geoFire.queryAtLocation(new GeoLocation(37, -133), 1.6);
    geoQuery.addGeoQueryEventListener(new GeoQueryEventListener() {
        @Override
        public void onKeyEntered(final String key, GeoLocation location) {
            arrayList.add(key);   
        ...

I think i'm supposed to add Listeners like so. How do I go about getting the BizName to populate a listView? It's great I have the keys but I want the values associated with those keys.

mRootRef.child("Businesses").child(key).addListenerForSingleValueEvent(new ValueEventListener(){
                @Override
                public void onDataChange(DataSnapshot dataSnapshot) {
                    Data data = dataSnapshot.getValue(Data.class);
                    data.getBizName();

                }
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807

1 Answers1

0

You'll indeed need to load the additional information for each key that you want to display. That takes (at most) a addListenerForSingleValueEvent or addValueListener for each key. Note that this is not nearly as expensive as many developers think, since the requests can be pipelined over the single connection that Firebase keeps open to the server. See Speed up fetching posts for my social network app by using query instead of observing a single event repeatedly

Loading your own data like this also means you'll need to define your own adapter between loading of the information and the view. Keep in mind that keys may move into and out of the range of the query, so ideally you should handle onKeyEntered and onKeyExited.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807