コード例 #1
0
ファイル: LocationManager.cs プロジェクト: PHOETUS/Popdit
 void IDisposable.Dispose()
 {
     if (!LocMgr.Equals(null))
     {
         LocMgr.Dispose();
     }
 }
コード例 #2
0
ファイル: LocationCheck.cs プロジェクト: itmit/asb.app
 protected override void Dispose(bool disposing)
 {
     _locationStatus           = null;
     _locationManager.Delegate = null;
     _locationManager.Dispose();
     base.Dispose(disposing);
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        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;
        }
コード例 #5
0
        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);
        }
コード例 #6
0
 public bool StopLocationStatusWatching()
 {
     _locationManager.Delegate = null;
     _locationManager.StopUpdatingLocation();
     _locationManager.Dispose();
     _locationManager = null;
     return(false);
 }
コード例 #7
0
 /// <summary>
 /// Stop monitoring.
 /// </summary>
 static partial void StopMonitoring()
 {
     LocationManager.LocationsUpdated -= LocationManagerOnLocationsUpdated;
     LocationManager.StopUpdatingLocation();
     // clear the manager
     locationManager.Dispose();
     locationManager = null;
 }
コード例 #8
0
        public void Dispose()
        {
            locationManager.StopUpdatingLocation();

            locationManager.Failed               -= OnFailed;
            locationManager.LocationsUpdated     -= OnLocationsUpdated;
            locationManager.AuthorizationChanged -= OnAuthorizationChanged;

            locationManager.Dispose();
        }
コード例 #9
0
 public override void ViewDidDisappear(bool animated)
 {
     if (locationManager != null)
     {
         locationManager.Delegate = null;
         locationManager.Dispose();
         locationManager = null;
     }
     base.ViewDidDisappear(animated);
 }
コード例 #10
0
ファイル: Compass.ios.cs プロジェクト: 07101994/Caboodle
        internal static void PlatformStop()
        {
            if (locationManager == null)
            {
                return;
            }

            locationManager.UpdatedHeading -= LocationManagerUpdatedHeading;
            locationManager.StopUpdatingHeading();
            locationManager.Dispose();
            locationManager = null;
        }
コード例 #11
0
        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);
        }
コード例 #12
0
ファイル: Compass.ios.cs プロジェクト: sung-su/maui
        void PlatformStop()
        {
            if (locationManager == null)
            {
                return;
            }

            locationManager.ShouldDisplayHeadingCalibration -= LocationManagerShouldDisplayHeadingCalibration;
            locationManager.UpdatedHeading -= LocationManagerUpdatedHeading;
            locationManager.StopUpdatingHeading();
            locationManager.Dispose();
            locationManager = null;
        }
コード例 #13
0
        public void Dispose()
        {
            if (_manager != null)
            {
                StopListening();

                _manager.AuthorizationChanged -= OnAuthorizationChanged;
                _manager.Failed -= OnFailed;

                _manager.Dispose();
                _manager = null;
            }
        }
コード例 #14
0
        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);
        }
コード例 #15
0
        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();
            }
        }
コード例 #16
0
        // 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);
        }
コード例 #17
0
        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);
        }
コード例 #18
0
ファイル: MapRenderer.cs プロジェクト: Hitcents/Xamarin.Forms
        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);
        }
コード例 #19
0
 public void Close()
 {
     StopScan();
     locationManager.Dispose();
 }
コード例 #20
0
 /// <summary>
 /// Disposes of held resources
 /// </summary>
 public void Dispose()
 {
     _locMgr.Dispose();
     _locMgr = null;
 }
コード例 #21
0
 public void Dispose()
 {
     _localtionManager?.Dispose();
 }
コード例 #22
0
        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);
                }
            }
        }
コード例 #23
0
 public void Dispose() => _locationManager.Dispose();