void HandleGeofenceAdded(object sender, GeofenceChangeEventArgs e) { _successfullyRestored = e.RequestId.SequenceEqual(_activeAlarms.Select(alarm => alarm.RequestId).ToArray()); Log.Debug(TAG, "HandleGeofenceAdded " + _successfullyRestored); _dbManager.EnableAlarms( _activeAlarms.Where(alarm => e.RequestId.Contains(alarm.RequestId)).ToList(), true); _geofenceManager.Stop(); }
void RestoreGeofences () { _dbManager = new DBManager (); _activeAlarms = _dbManager.GetAll ().Where (alarm => alarm.Enabled).ToList (); _dbManager.EnableAlarms (_activeAlarms, false); _geofenceManager = new GeofenceManager (); _geofenceManager.Error += (sender, e) => AnyError (); _geofenceManager.Started += HandleStarted; _geofenceManager.FailedToStart += (sender, e) => AnyError (); _geofenceManager.FailedToStartWithResolution += (sender, e) => AnyError (); _geofenceManager.Stoped += HandleStoped; _geofenceManager.GeofenceAdded += HandleGeofenceAdded; _geofenceManager.Start (); }
void RestoreGeofences() { _dbManager = new DBManager(); _activeAlarms = _dbManager.GetAll().Where(alarm => alarm.Enabled).ToList(); _dbManager.EnableAlarms(_activeAlarms, false); _geofenceManager = new GeofenceManager(); _geofenceManager.Error += (sender, e) => AnyError(); _geofenceManager.Started += HandleStarted; _geofenceManager.FailedToStart += (sender, e) => AnyError(); _geofenceManager.FailedToStartWithResolution += (sender, e) => AnyError(); _geofenceManager.Stoped += HandleStoped; _geofenceManager.GeofenceAdded += HandleGeofenceAdded; _geofenceManager.Start(); }