public async Task<bool> StartRecordingTrip()
{
if (IsBusy || IsRecording)
return false;
//Since the current trip screen is typically the first screen opened, let's do an up-front check to ensure the user is authenticated
await AzureClient.AzureClient.CheckIsAuthTokenValid();
try
{
if (CurrentPosition == null)
{
if (CrossDeviceInfo.Current.Platform == Plugin.DeviceInfo.Abstractions.Platform.Android ||
CrossDeviceInfo.Current.Platform == Plugin.DeviceInfo.Abstractions.Platform.iOS ||
CrossDeviceInfo.Current.Platform == Plugin.DeviceInfo.Abstractions.Platform.WindowsPhone)
{
Acr.UserDialogs.UserDialogs.Instance.Toast(
new Acr.UserDialogs.ToastConfig(Acr.UserDialogs.ToastEvent.Success,
"Waiting for current location.")
{
Duration = TimeSpan.FromSeconds(3),
TextColor = System.Drawing.Color.White,
BackgroundColor = System.Drawing.Color.FromArgb(96, 125, 139)
});
}
return false;
}
//Connect to the OBD device
if (obdDataProcessor != null)
{
await obdDataProcessor.ConnectToObdDevice(true);
CurrentTrip.HasSimulatedOBDData = obdDataProcessor.IsObdDeviceSimulated;
}
CurrentTrip.RecordedTimeStamp = DateTime.UtcNow;
IsRecording = true;
Logger.Instance.Track("StartRecording");
//add start point
CurrentTrip.Points.Add(new TripPoint
{
RecordedTimeStamp = DateTime.UtcNow,
Latitude = CurrentPosition.Latitude,
Longitude = CurrentPosition.Longitude,
Sequence = CurrentTrip.Points.Count,
});
}
catch (Exception ex)
{
Logger.Instance.Report(ex);
}
return IsRecording;
}