void IDisposable.Dispose() { if (!LocMgr.Equals(null)) { LocMgr.Dispose(); } }
protected override void Dispose(bool disposing) { _locationStatus = null; _locationManager.Delegate = null; _locationManager.Dispose(); base.Dispose(disposing); }
static Task <PermissionStatus> RequestLocationAsync() { locationManager = new CLLocationManager(); var tcs = new TaskCompletionSource <PermissionStatus>(locationManager); locationManager.AuthorizationChanged += LocationAuthCallback; locationManager.RequestWhenInUseAuthorization(); return(tcs.Task); void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e) { if (e?.Status == null || e.Status == CLAuthorizationStatus.NotDetermined) { return; } if (locationManager != null) { locationManager.AuthorizationChanged -= LocationAuthCallback; } tcs?.TrySetResult(GetLocationStatus()); locationManager?.Dispose(); locationManager = null; } }
private static void OnLocationRequested(object sender, CLAuthorizationChangedEventArgs e) { if (e.Status == CLAuthorizationStatus.NotDetermined) { return; } if (_requests.TryRemove(AuthorizationType.LocationWhenUse, out var times1)) { for (int i = 0; i < times1; i++) { RaiseAuthorizationRequested(AuthorizationType.LocationWhenUse, e.Status.ToShared(false)); } } if (_requests.TryRemove(AuthorizationType.LocationAlways, out var times2)) { for (int i = 0; i < times2; i++) { RaiseAuthorizationRequested(AuthorizationType.LocationAlways, e.Status.ToShared(true)); } } _locationManager.AuthorizationChanged -= OnLocationRequested; _locationManager.Dispose(); _locationManager = null; }
protected override void Dispose(bool disposing) { if (_disposed) { return; } _disposed = true; if (disposing) { if (Element != null) { var mapModel = (Map)Element; MessagingCenter.Unsubscribe <Map, MapSpan>(this, MoveMessageName); ((ObservableCollection <Pin>)mapModel.Pins).CollectionChanged -= OnPinCollectionChanged; ((ObservableCollection <MapElement>)mapModel.MapElements).CollectionChanged -= OnMapElementCollectionChanged; foreach (Pin pin in mapModel.Pins) { pin.PropertyChanged -= PinOnPropertyChanged; } } var mkMapView = (MKMapView)Control; mkMapView.DidSelectAnnotationView -= MkMapViewOnAnnotationViewSelected; mkMapView.RegionChanged -= MkMapViewOnRegionChanged; mkMapView.GetViewForAnnotation = null; mkMapView.OverlayRenderer = null; if (mkMapView.Delegate != null) { mkMapView.Delegate.Dispose(); mkMapView.Delegate = null; } mkMapView.RemoveFromSuperview(); #if __MOBILE__ mkMapView.RemoveGestureRecognizer(_mapClickedGestureRecognizer); _mapClickedGestureRecognizer.Dispose(); _mapClickedGestureRecognizer = null; if (FormsMaps.IsiOs9OrNewer) { // This renderer is done with the MKMapView; we can put it in the pool // for other rendererers to use in the future MapPool.Add(mkMapView); } #endif // For iOS versions < 9, the MKMapView will be disposed in ViewRenderer's Dispose method if (_locationManager != null) { _locationManager.Dispose(); _locationManager = null; } _lastTouchedView = null; } base.Dispose(disposing); }
public bool StopLocationStatusWatching() { _locationManager.Delegate = null; _locationManager.StopUpdatingLocation(); _locationManager.Dispose(); _locationManager = null; return(false); }
/// <summary> /// Stop monitoring. /// </summary> static partial void StopMonitoring() { LocationManager.LocationsUpdated -= LocationManagerOnLocationsUpdated; LocationManager.StopUpdatingLocation(); // clear the manager locationManager.Dispose(); locationManager = null; }
public void Dispose() { locationManager.StopUpdatingLocation(); locationManager.Failed -= OnFailed; locationManager.LocationsUpdated -= OnLocationsUpdated; locationManager.AuthorizationChanged -= OnAuthorizationChanged; locationManager.Dispose(); }
public override void ViewDidDisappear(bool animated) { if (locationManager != null) { locationManager.Delegate = null; locationManager.Dispose(); locationManager = null; } base.ViewDidDisappear(animated); }
internal static void PlatformStop() { if (locationManager == null) { return; } locationManager.UpdatedHeading -= LocationManagerUpdatedHeading; locationManager.StopUpdatingHeading(); locationManager.Dispose(); locationManager = null; }
public override void ViewDidDisappear(bool animated) { if (locationManager != null) { locationManager.Delegate = null; locationManager.Dispose(); locationManager = null; } Mvx.Resolve <IMvxMessenger>().Unsubscribe <TimeMessage>(mTimeToken); base.ViewDidDisappear(animated); }
void PlatformStop() { if (locationManager == null) { return; } locationManager.ShouldDisplayHeadingCalibration -= LocationManagerShouldDisplayHeadingCalibration; locationManager.UpdatedHeading -= LocationManagerUpdatedHeading; locationManager.StopUpdatingHeading(); locationManager.Dispose(); locationManager = null; }
public void Dispose() { if (_manager != null) { StopListening(); _manager.AuthorizationChanged -= OnAuthorizationChanged; _manager.Failed -= OnFailed; _manager.Dispose(); _manager = null; } }
protected override void Dispose(bool disposing) { if (_disposed) { return; } _disposed = true; if (disposing) { if (Element != null) { var mapModel = (Map)Element; MessagingCenter.Unsubscribe <Map, MapSpan>(this, MoveMessageName); ((ObservableCollection <Pin>)mapModel.Pins).CollectionChanged -= OnCollectionChanged; } var mkMapView = (MKMapView)Control; mkMapView.RegionChanged -= MkMapViewOnRegionChanged; mkMapView.GetViewForAnnotation = null; mkMapView.Delegate.Dispose(); mkMapView.Delegate = null; mkMapView.RemoveFromSuperview(); #if __MOBILE__ if (FormsMaps.IsiOs9OrNewer) { // This renderer is done with the MKMapView; we can put it in the pool // for other rendererers to use in the future MapPool.Add(mkMapView); } #endif // For iOS versions < 9, the MKMapView will be disposed in ViewRenderer's Dispose method if (_locationManager != null) { _locationManager.Dispose(); _locationManager = null; } } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { base.Dispose(disposing); if (searchController != null) { searchController.Dispose(); searchController = null; } if (mapViewDelegate != null) { mapViewDelegate.Dispose(); mapViewDelegate = null; } if (locationManager != null) { locationManager.Dispose(); } }
// iOS 9/10 have some issues with releasing memory from map views; each one we create allocates // a bunch of memory we can never get back. Until that's fixed, we'll just reuse MKMapViews // as much as possible to prevent creating new ones and losing more memory // For the time being, we don't want ViewRenderer handling disposal of the MKMapView // if we're on iOS 9 or 10; during Dispose we'll be putting the MKMapView in a pool instead protected override void Dispose(bool disposing) { if (_disposed) { return; } _disposed = true; if (disposing) { if (Element != null) { var mapModel = (Map)Element; MessagingCenter.Unsubscribe <Map, MapSpan>(this, MoveMessageName); ((ObservableCollection <Pin>)mapModel.Pins).CollectionChanged -= OnCollectionChanged; } var mkMapView = (MKMapView)Control; mkMapView.RegionChanged -= MkMapViewOnRegionChanged; mkMapView.GetViewForAnnotation = null; if (mkMapView.Delegate != null) { mkMapView.Delegate.Dispose(); mkMapView.Delegate = null; } mkMapView.RemoveFromSuperview(); // For iOS versions < 9, the MKMapView will be disposed in ViewRenderer's Dispose method if (_locationManager != null) { _locationManager.Dispose(); _locationManager = null; } _lastTouchedView = null; } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { RemoveEvents(Element); _behavior.Destroy(); if (Control != null) { Control.Delegate = null; } if (_locationManager != null) { _locationManager.Dispose(); _locationManager = null; } } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { if (Element != null) { var mapModel = (Map)Element; MessagingCenter.Unsubscribe <Map, MapSpan>(this, "MapMoveToRegion"); ((ObservableCollection <Pin>)mapModel.Pins).CollectionChanged -= OnCollectionChanged; } var mkMapView = (MKMapView)Control; mkMapView.RegionChanged -= MkMapViewOnRegionChanged; if (_locationManager != null) { _locationManager.Dispose(); _locationManager = null; } } base.Dispose(disposing); }
public void Close() { StopScan(); locationManager.Dispose(); }
/// <summary> /// Disposes of held resources /// </summary> public void Dispose() { _locMgr.Dispose(); _locMgr = null; }
public void Dispose() { _localtionManager?.Dispose(); }
internal static void PlatformStart(SensorSpeed sensorSpeed, Action <CompassData> handler) { var useSyncContext = false; var locationManager = new CLLocationManager(); switch (sensorSpeed) { case SensorSpeed.Fastest: locationManager.HeadingFilter = FastestFilter; locationManager.DesiredAccuracy = CLLocation.AccurracyBestForNavigation; break; case SensorSpeed.Game: locationManager.HeadingFilter = GameFilter; locationManager.DesiredAccuracy = CLLocation.AccurracyBestForNavigation; break; case SensorSpeed.Normal: locationManager.HeadingFilter = NormalFilter; locationManager.DesiredAccuracy = CLLocation.AccuracyBest; useSyncContext = true; break; case SensorSpeed.Ui: locationManager.HeadingFilter = UiFilter; locationManager.DesiredAccuracy = CLLocation.AccuracyBest; useSyncContext = true; break; } MonitorCTS.Token.Register(CancelledToken, useSyncContext); locationManager.UpdatedHeading += LocationManagerUpdatedHeading; locationManager.StartUpdatingHeading(); void CancelledToken() { if (locationManager != null) { locationManager.UpdatedHeading -= LocationManagerUpdatedHeading; locationManager.StopUpdatingHeading(); locationManager.Dispose(); locationManager = null; } DisposeToken(); } void LocationManagerUpdatedHeading(object sender, CLHeadingUpdatedEventArgs e) { var data = new CompassData(e.NewHeading.MagneticHeading); if (useSyncContext) { Platform.BeginInvokeOnMainThread(() => handler?.Invoke(data)); } else { handler?.Invoke(data); } } }
public void Dispose() => _locationManager.Dispose();