Ejemplo n.º 1
0
        public void OnLocationChanged(Location location)
        {
            _batteryHelper.CheckStoreBatteryLevel(TimeSpan.FromMinutes(10));

            positionCache.Distance = currentProfile.DistanceDeltaLowTracking;
            PositionEntry positionEntry = location.ToPositionEntry();

            positionCache.Add(positionEntry);
            Log.Trace($"GoogleApi: Location was changed {positionCache.PreviousDistance}");

            positionEntry.DistanceBetweenPreviousPosition = positionCache.PreviousDistance;

            if (positionCache.Check(TimeSpan.FromSeconds(currentProfile.TimePeriodLowTracking)))
            {
                // Enable Low Tracking if not already enabled
                if (currentRequestProfile != currentProfile.LowTrackingProfile)
                {
                    Log.Info("LowTracking");
                    currentRequestProfile = currentProfile.LowTrackingProfile;
                    RestartLocationUpdates();
                }
            }
            else if (currentRequestProfile != currentProfile.HighTrackingProfile)
            {
                Log.Info("HighTracking");
                currentRequestProfile = currentProfile.HighTrackingProfile;
                RestartLocationUpdates();
            }

            if (!positionEntry.Equals(previousPositionEntry))
            {
                positionEntryRepository.Add(positionEntry);
            }
        }
Ejemplo n.º 2
0
        private LocationRequest CreateLocationRequest(LocationRequestProfile profile)
        {
            var request = new LocationRequest();

            request.SetPriority(profile.Priority);
            request.SetInterval(profile.Interval);

            return(request);
        }
Ejemplo n.º 3
0
 void GoogleApiClient.IConnectionCallbacks.OnConnected(Bundle connectionHint)
 {
     Log.Info("GoogleApi: Connected!");
     currentRequestProfile = currentProfile.HighTrackingProfile;
     StartLocationUpdates();
 }
Ejemplo n.º 4
0
 public void RequestUpdateNow()
 {
     Log.Debug("RequestUpdateNow: HighTrackingProfile");
     currentRequestProfile = currentProfile.HighTrackingProfile;
     RestartLocationUpdates();
 }
Ejemplo n.º 5
0
        public void StartLocationUpdates(LocationRequestProfile profile)
        {
            LocationRequest req = CreateLocationRequest(profile);

            LocationServices.FusedLocationApi.RequestLocationUpdates(client, req, this);
        }