mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-20 03:56:29 +02:00
Closing lock and returning bike speeded up.
This commit is contained in:
parent
e4adeb908c
commit
db9c288584
70 changed files with 933 additions and 902 deletions
|
@ -1,5 +1,6 @@
|
|||
using Serilog;
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TINK.Model.Device;
|
||||
using Xamarin.Essentials;
|
||||
|
@ -8,24 +9,22 @@ namespace TINK.Model.Services.Geolocation
|
|||
{
|
||||
public class LastKnownGeolocationService : IGeolocation
|
||||
{
|
||||
/// <summary> Timeout for geolocation request operations.</summary>
|
||||
private const int GEOLOCATIONREQUEST_TIMEOUT_MS = 5000;
|
||||
|
||||
private IGeolodationDependent Dependent { get; }
|
||||
|
||||
public LastKnownGeolocationService(IGeolodationDependent dependent)
|
||||
{
|
||||
Dependent = dependent;
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Gets the current location.</summary>
|
||||
/// <param name="cancelationToken">Token to cancel request for geolocation.</param>
|
||||
/// <param name="timeStamp">Time when geolocation is of interest. Is used to determine whether cached geoloation can be used or not.</param>
|
||||
public async Task<Location> GetAsync(DateTime? timeStamp = null)
|
||||
public async Task<Location> GetAsync(CancellationToken? cancelationToken = null, DateTime? timeStamp = null)
|
||||
{
|
||||
Location location;
|
||||
try
|
||||
{
|
||||
var request = new GeolocationRequest(GeolocationAccuracy.Medium, TimeSpan.FromMilliseconds(GEOLOCATIONREQUEST_TIMEOUT_MS));
|
||||
location = await Xamarin.Essentials.Geolocation.GetLocationAsync(request);
|
||||
location = await Xamarin.Essentials.Geolocation.GetLastKnownLocationAsync();
|
||||
}
|
||||
catch (FeatureNotSupportedException fnsEx)
|
||||
{
|
||||
|
@ -59,13 +58,14 @@ namespace TINK.Model.Services.Geolocation
|
|||
return location;
|
||||
}
|
||||
|
||||
return await Xamarin.Essentials.Geolocation.GetLocationAsync();
|
||||
return await new GeolocationService(Dependent).GetAsync(cancelationToken, timeStamp);
|
||||
}
|
||||
|
||||
/// <summary> If true location data returned is simulated.</summary>
|
||||
public bool IsSimulation { get => false; }
|
||||
|
||||
public TimeSpan MaxAge => new TimeSpan(0, 3, 0);
|
||||
/// <summary> Maximum age allowed for location info. </summary>
|
||||
public TimeSpan MaxAge => new TimeSpan(0, 3 /*minutes*/, 0);
|
||||
|
||||
public bool IsGeolcationEnabled => Dependent.IsGeolcationEnabled;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue