Exemple #1
0
        internal SingleLocationListener(LocationManager manager, float desiredAccuracy, IEnumerable <string> activeProviders)
        {
            this.desiredAccuracy = desiredAccuracy;

            this.activeProviders = new HashSet <string>(activeProviders);

            foreach (var provider in activeProviders)
            {
                var location = manager.GetLastKnownLocation(provider);
                if (location != null && GeolocationImplementation.IsBetterLocation(location, BestLocation))
                {
                    BestLocation = location;
                }
            }
        }
Exemple #2
0
        void ILocationListener.OnLocationChanged(AndroidLocation location)
        {
            if (location.Accuracy <= desiredAccuracy)
            {
                if (wasRaised)
                {
                    return;
                }

                wasRaised = true;

                LocationHandler?.Invoke(location);
                return;
            }

            lock (locationSync)
            {
                if (GeolocationImplementation.IsBetterLocation(location, BestLocation))
                {
                    BestLocation = location;
                }
            }
        }