Esempio n. 1
0
        internal void childRemoved(DataSnapshot dataSnapshot)
        {
            string       key  = dataSnapshot.Key;
            LocationInfo info = GeoUtils.getMapSafe(key, locationInfos);

            if (info != null)
            {
                ValueChangedListenerSetup vs = new ValueChangedListenerSetup(geoFire.getDatabaseRefForKey(key), true, (s) => {
                    if (s.DatabaseError == null)
                    {
                        lock (Lock) {
                            GeoLocation location = GeoFire.getLocationValue(dataSnapshot);
                            GeoHash hash         = (location != null) ? new GeoHash(location) : null;
                            if (hash == null || !geoHashQueriesContainGeoHash(hash))
                            {
                                LocationInfo _info = GeoUtils.getMapSafe(key, locationInfos);
                                locationInfos.Remove(key);
                                if (_info != null && _info.inGeoQuery)
                                {
                                    foreach (GeoQueryEventListener listener in eventListeners)
                                    {
                                        geoFire.raiseEvent(() => {
                                            listener.onKeyExited(key);
                                        });
                                    }
                                }
                            }
                        }
                    }
                });
            }
        }
Esempio n. 2
0
 /**
  * Creates a new GeoQuery object centered at the given location and with the given radius.
  * @param geoFire The GeoFire object this GeoQuery uses
  * @param center The center of this query
  * @param radius The radius of this query, in kilometers
  */
 internal GeoQuery(GeoFire geoFire, GeoLocation center, double radius)
 {
     this.geoFire = geoFire;
     this.center  = center;
     // convert from kilometers to meters
     this.radius      = radius * 1000;
     childEventLister = new GeoQueryChildEventListener(this);
 }
Esempio n. 3
0
        internal virtual void initializeFirebase()
        {
            FirebaseApp app = FirebaseApp.DefaultInstance;

            app.SetEditorDatabaseUrl(geoFireUrl);
            if (app.Options.DatabaseUrl != null)
            {
                app.SetEditorDatabaseUrl(app.Options.DatabaseUrl);
            }
            geoFire = new GeoFire(FirebaseDatabase.DefaultInstance.GetReference("/geo"));
        }
Esempio n. 4
0
        internal void childChanged(DataSnapshot dataSnapshot)
        {
            GeoLocation location = GeoFire.getLocationValue(dataSnapshot);

            if (location != null)
            {
                this.updateLocationInfo(dataSnapshot.Key, location);
            }
            else
            {
                // throw an error in future?
            }
        }
Esempio n. 5
0
 public void onDataChange(DataSnapshot dataSnapshot)
 {
     if (dataSnapshot.Value == null)
     {
         this.callback.onLocationResult(dataSnapshot.Key, null);
     }
     else
     {
         GeoLocation location = GeoFire.getLocationValue(dataSnapshot);
         if (location != null)
         {
             this.callback.onLocationResult(dataSnapshot.Key, location);
         }
         else
         {
             string message = "GeoFire data has invalid format: " + dataSnapshot.Value;
             this.callback.onCancelled(new ExDatabaseError(new Exception(message)));
         }
     }
 }