コード例 #1
0
ファイル: GeoQuery.cs プロジェクト: kirinchen/geofire-cSharp
        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);
                                        });
                                    }
                                }
                            }
                        }
                    }
                });
            }
        }
コード例 #2
0
ファイル: GeoQuery.cs プロジェクト: kirinchen/geofire-cSharp
 /**
  * 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);
 }
コード例 #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"));
        }
コード例 #4
0
ファイル: GeoQuery.cs プロジェクト: kirinchen/geofire-cSharp
        internal void childChanged(DataSnapshot dataSnapshot)
        {
            GeoLocation location = GeoFire.getLocationValue(dataSnapshot);

            if (location != null)
            {
                this.updateLocationInfo(dataSnapshot.Key, location);
            }
            else
            {
                // throw an error in future?
            }
        }
コード例 #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)));
         }
     }
 }