mirror of
https://dev.azure.com/TeilRad/sharee.bike%20App/_git/Code
synced 2025-04-21 20:46:28 +02:00
Version 3.0.338
This commit is contained in:
parent
573fe77e12
commit
0468955d49
751 changed files with 62747 additions and 60672 deletions
|
@ -5,91 +5,91 @@ using TINK.ViewModel.Bikes.Bike;
|
|||
|
||||
namespace TINK.ViewModel
|
||||
{
|
||||
public class MyBikeInUseStateInfoProvider : IInUseStateInfoProvider
|
||||
{
|
||||
/// <summary> Gets reserved into display text. </summary>
|
||||
/// <todo>Log unexpeced states.</todo>
|
||||
/// <returns>Display text</returns>
|
||||
public string GetReservedInfo(
|
||||
TimeSpan? remainingTime,
|
||||
string stationId = null,
|
||||
string code = null)
|
||||
{
|
||||
if (remainingTime == null)
|
||||
{
|
||||
// Reamining time is not available.
|
||||
if (stationId == null)
|
||||
{
|
||||
public class MyBikeInUseStateInfoProvider : IInUseStateInfoProvider
|
||||
{
|
||||
/// <summary> Gets reserved into display text. </summary>
|
||||
/// <todo>Log unexpeced states.</todo>
|
||||
/// <returns>Display text</returns>
|
||||
public string GetReservedInfo(
|
||||
TimeSpan? remainingTime,
|
||||
string stationId = null,
|
||||
string code = null)
|
||||
{
|
||||
if (remainingTime == null)
|
||||
{
|
||||
// Reamining time is not available.
|
||||
if (stationId == null)
|
||||
{
|
||||
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
// Code is not avilable
|
||||
return string.Format(AppResources.StatusTextReservationExpiredMaximumReservationTime, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
// Code is not avilable
|
||||
return string.Format(AppResources.StatusTextReservationExpiredMaximumReservationTime, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
|
||||
return string.Format(AppResources.StatusTextReservationExpiredCodeMaxReservationTime, code, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
return string.Format(AppResources.StatusTextReservationExpiredCodeMaxReservationTime, code, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
return string.Format(AppResources.StatusTextReservationExpiredLocationMaxReservationTime, stationId, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
if (string.IsNullOrEmpty(code))
|
||||
{
|
||||
return string.Format(AppResources.StatusTextReservationExpiredLocationMaxReservationTime, stationId, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
|
||||
return string.Format(AppResources.StatusTextReservationExpiredCodeLocationMaxReservationTime, code, stationId, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
return string.Format(AppResources.StatusTextReservationExpiredCodeLocationMaxReservationTime, code, stationId, StateRequestedInfo.MaximumReserveTime.Minutes);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(stationId))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(code))
|
||||
{
|
||||
return string.Format(
|
||||
AppResources.StatusTextReservationExpiredCodeLocationReservationTime,
|
||||
code,
|
||||
ViewModelHelper.GetStationName(stationId),
|
||||
remainingTime.Value.Minutes);
|
||||
}
|
||||
if (!string.IsNullOrEmpty(stationId))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(code))
|
||||
{
|
||||
return string.Format(
|
||||
AppResources.StatusTextReservationExpiredCodeLocationReservationTime,
|
||||
code,
|
||||
ViewModelHelper.GetStationName(stationId),
|
||||
remainingTime.Value.Minutes);
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
AppResources.StatusTextReservationExpiredLocationReservationTime,
|
||||
ViewModelHelper.GetStationName(stationId),
|
||||
remainingTime.Value.Minutes);
|
||||
}
|
||||
return string.Format(
|
||||
AppResources.StatusTextReservationExpiredLocationReservationTime,
|
||||
ViewModelHelper.GetStationName(stationId),
|
||||
remainingTime.Value.Minutes);
|
||||
}
|
||||
|
||||
return string.Format(
|
||||
AppResources.StatusTextReservationExpiredRemaining,
|
||||
remainingTime.Value.Minutes);
|
||||
}
|
||||
return string.Format(
|
||||
AppResources.StatusTextReservationExpiredRemaining,
|
||||
remainingTime.Value.Minutes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets booked into display text.
|
||||
/// </summary>
|
||||
/// <todo>Log unexpeced states.</todo>
|
||||
/// <returns>Display text</returns>
|
||||
public string GetBookedInfo(
|
||||
DateTime? from,
|
||||
string stationId = null,
|
||||
string code = null)
|
||||
{
|
||||
if (from == null)
|
||||
{
|
||||
return AppResources.StatusTextBooked;
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets booked into display text.
|
||||
/// </summary>
|
||||
/// <todo>Log unexpeced states.</todo>
|
||||
/// <returns>Display text</returns>
|
||||
public string GetBookedInfo(
|
||||
DateTime? from,
|
||||
string stationId = null,
|
||||
string code = null)
|
||||
{
|
||||
if (from == null)
|
||||
{
|
||||
return AppResources.StatusTextBooked;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(code))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(stationId))
|
||||
{
|
||||
return string.Format(
|
||||
AppResources.StatusTextBookedCodeLocationSince,
|
||||
code,
|
||||
ViewModelHelper.GetStationName(stationId),
|
||||
from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
||||
}
|
||||
if (!string.IsNullOrEmpty(code))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(stationId))
|
||||
{
|
||||
return string.Format(
|
||||
AppResources.StatusTextBookedCodeLocationSince,
|
||||
code,
|
||||
ViewModelHelper.GetStationName(stationId),
|
||||
from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
||||
}
|
||||
|
||||
return string.Format(AppResources.StatusTextBookedCodeSince, code, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
||||
}
|
||||
return string.Format(AppResources.StatusTextBookedCodeSince, code, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
||||
}
|
||||
|
||||
return string.Format(AppResources.StatusTextBookedSince, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
||||
}
|
||||
}
|
||||
return string.Format(AppResources.StatusTextBookedSince, from.Value.ToString(BikeViewModelBase.TIMEFORMAT));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,246 +26,246 @@ using Xamarin.Forms;
|
|||
|
||||
namespace TINK.ViewModel.MyBikes
|
||||
{
|
||||
public class MyBikesPageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> Holds the stations to get station names form station ids. </summary>
|
||||
private IEnumerable<IStation> Stations { get; }
|
||||
public class MyBikesPageViewModel : BikesViewModel, INotifyCollectionChanged, INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> Holds the stations to get station names form station ids. </summary>
|
||||
private IEnumerable<IStation> Stations { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Constructs bike collection view model in case information about occupied bikes is available.
|
||||
/// </summary>
|
||||
/// <param name="p_oUser">Mail address of active user.</param>
|
||||
/// <param name="isReportLevelVerbose">True if report level is verbose, false if not.</param>
|
||||
/// <param name="permissions">Holds object to query location permisions.</param>
|
||||
/// <param name="bluetoothLE">Holds object to query bluetooth state.</param>
|
||||
/// <param name="runtimPlatform">Specifies on which platform code is run.</param>
|
||||
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
|
||||
/// <param name="connectorFactory">Connects system to copri.</param>
|
||||
/// <param name="lockService">Service to control lock retrieve info.</param>
|
||||
/// <param name="stations">Stations to get station name from station id.</param>
|
||||
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
||||
/// <param name="postAction">Executes actions on GUI thread.</param>
|
||||
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
|
||||
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
|
||||
/// <param name="openUrlInBrowser">Delegate to open browser.</param>
|
||||
public MyBikesPageViewModel(
|
||||
User p_oUser,
|
||||
ILocationPermission permissions,
|
||||
IBluetoothLE bluetoothLE,
|
||||
string runtimPlatform,
|
||||
Func<bool> isConnectedDelegate,
|
||||
Func<bool, IConnector> connectorFactory,
|
||||
IGeolocation geolocation,
|
||||
ILocksService lockService,
|
||||
IEnumerable<IStation> stations,
|
||||
PollingParameters p_oPolling,
|
||||
Action<SendOrPostCallback, object> postAction,
|
||||
ISmartDevice smartDevice,
|
||||
IViewService viewService,
|
||||
Action<string> openUrlInBrowser) : base(p_oUser, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, p_oPolling, postAction, smartDevice, viewService, openUrlInBrowser, () => new MyBikeInUseStateInfoProvider())
|
||||
{
|
||||
CollectionChanged += (sender, eventargs) =>
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible)));
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText)));
|
||||
};
|
||||
/// <summary>
|
||||
/// Constructs bike collection view model in case information about occupied bikes is available.
|
||||
/// </summary>
|
||||
/// <param name="p_oUser">Mail address of active user.</param>
|
||||
/// <param name="isReportLevelVerbose">True if report level is verbose, false if not.</param>
|
||||
/// <param name="permissions">Holds object to query location permisions.</param>
|
||||
/// <param name="bluetoothLE">Holds object to query bluetooth state.</param>
|
||||
/// <param name="runtimPlatform">Specifies on which platform code is run.</param>
|
||||
/// <param name="isConnectedDelegate">Returns if mobile is connected to web or not.</param>
|
||||
/// <param name="connectorFactory">Connects system to copri.</param>
|
||||
/// <param name="lockService">Service to control lock retrieve info.</param>
|
||||
/// <param name="stations">Stations to get station name from station id.</param>
|
||||
/// <param name="p_oPolling"> Holds whether to poll or not and the periode leght is polling is on. </param>
|
||||
/// <param name="postAction">Executes actions on GUI thread.</param>
|
||||
/// <param name="smartDevice">Provides info about the smart device (phone, tablet, ...).</param>
|
||||
/// <param name="viewService">Interface to actuate methodes on GUI.</param>
|
||||
/// <param name="openUrlInBrowser">Delegate to open browser.</param>
|
||||
public MyBikesPageViewModel(
|
||||
User p_oUser,
|
||||
ILocationPermission permissions,
|
||||
IBluetoothLE bluetoothLE,
|
||||
string runtimPlatform,
|
||||
Func<bool> isConnectedDelegate,
|
||||
Func<bool, IConnector> connectorFactory,
|
||||
IGeolocation geolocation,
|
||||
ILocksService lockService,
|
||||
IEnumerable<IStation> stations,
|
||||
PollingParameters p_oPolling,
|
||||
Action<SendOrPostCallback, object> postAction,
|
||||
ISmartDevice smartDevice,
|
||||
IViewService viewService,
|
||||
Action<string> openUrlInBrowser) : base(p_oUser, permissions, bluetoothLE, runtimPlatform, isConnectedDelegate, connectorFactory, geolocation, lockService, p_oPolling, postAction, smartDevice, viewService, openUrlInBrowser, () => new MyBikeInUseStateInfoProvider())
|
||||
{
|
||||
CollectionChanged += (sender, eventargs) =>
|
||||
{
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible)));
|
||||
OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText)));
|
||||
};
|
||||
|
||||
Stations = stations ?? throw new ArgumentException(nameof(stations));
|
||||
}
|
||||
Stations = stations ?? throw new ArgumentException(nameof(stations));
|
||||
}
|
||||
|
||||
/// <summary> Returns if info about the fact that user did not request or book any bikes is visible or not.<summary>
|
||||
/// Gets message that logged in user has not booked any bikes.
|
||||
/// </summary>
|
||||
public bool IsNoBikesOccupiedVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return Count <= 0 && IsIdle == true;
|
||||
}
|
||||
}
|
||||
/// <summary> Returns if info about the fact that user did not request or book any bikes is visible or not.<summary>
|
||||
/// Gets message that logged in user has not booked any bikes.
|
||||
/// </summary>
|
||||
public bool IsNoBikesOccupiedVisible
|
||||
{
|
||||
get
|
||||
{
|
||||
return Count <= 0 && IsIdle == true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Info about the fact that user did not request or book any bikes. </summary>
|
||||
public string NoBikesOccupiedText
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsNoBikesOccupiedVisible
|
||||
? $"Momentan sind keine Fahrräder auf Benutzer {ActiveUser?.Mail} reserviert/ gebucht."
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
/// <summary> Info about the fact that user did not request or book any bikes. </summary>
|
||||
public string NoBikesOccupiedText
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsNoBikesOccupiedVisible
|
||||
? $"Momentan sind keine Fahrräder auf Benutzer {ActiveUser?.Mail} reserviert/ gebucht."
|
||||
: string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when page is shown.
|
||||
/// Starts update process.
|
||||
/// </summary>
|
||||
public async Task OnAppearing()
|
||||
{
|
||||
// Get my bikes from COPRI
|
||||
Log.ForContext<MyBikesPageViewModel>().Information("User request to show page MyBikes/ page re-appearing");
|
||||
/// <summary>
|
||||
/// Invoked when page is shown.
|
||||
/// Starts update process.
|
||||
/// </summary>
|
||||
public async Task OnAppearing()
|
||||
{
|
||||
// Get my bikes from COPRI
|
||||
Log.ForContext<MyBikesPageViewModel>().Information("User request to show page MyBikes/ page re-appearing");
|
||||
|
||||
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
|
||||
ActionText = AppResources.ActivityTextMyBikesLoadingBikes;
|
||||
|
||||
var bikesOccupied = await ConnectorFactory(IsConnected).Query.GetBikesOccupiedAsync();
|
||||
var bikesOccupied = await ConnectorFactory(IsConnected).Query.GetBikesOccupiedAsync();
|
||||
|
||||
Exception = bikesOccupied.Exception; // Update communication error from query for bikes occupied.
|
||||
Exception = bikesOccupied.Exception; // Update communication error from query for bikes occupied.
|
||||
|
||||
var lockIdList = bikesOccupied.Response
|
||||
.GetLockIt()
|
||||
.Cast<Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo>()
|
||||
.Select(x => x.LockInfo)
|
||||
.ToList();
|
||||
var lockIdList = bikesOccupied.Response
|
||||
.GetLockIt()
|
||||
.Cast<Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo>()
|
||||
.Select(x => x.LockInfo)
|
||||
.ToList();
|
||||
|
||||
if (LockService is ILocksServiceFake serviceFake)
|
||||
{
|
||||
serviceFake.UpdateSimulation(bikesOccupied.Response);
|
||||
}
|
||||
if (LockService is ILocksServiceFake serviceFake)
|
||||
{
|
||||
serviceFake.UpdateSimulation(bikesOccupied.Response);
|
||||
}
|
||||
|
||||
// Check bluetooth and location permission and states
|
||||
ActionText = AppResources.ActivityTextCheckBluetoothState;
|
||||
// Check bluetooth and location permission and states
|
||||
ActionText = AppResources.ActivityTextCheckBluetoothState;
|
||||
|
||||
if (bikesOccupied.Response.FirstOrDefault(x => x is Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo btBike) != null
|
||||
&& RuntimePlatform == Device.Android)
|
||||
{
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status != Status.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestAsync();
|
||||
if (bikesOccupied.Response.FirstOrDefault(x => x is Model.Bikes.BikeInfoNS.BluetoothLock.BikeInfo btBike) != null
|
||||
&& RuntimePlatform == Device.Android)
|
||||
{
|
||||
// Check location permission
|
||||
var status = await PermissionsService.CheckStatusAsync();
|
||||
if (status != Status.Granted)
|
||||
{
|
||||
var permissionResult = await PermissionsService.RequestAsync();
|
||||
|
||||
if (permissionResult != Status.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
if (permissionResult != Status.Granted)
|
||||
{
|
||||
var dialogResult = await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationPermissionOpenDialog,
|
||||
AppResources.MessageAnswerYes,
|
||||
AppResources.MessageAnswerNo);
|
||||
|
||||
if (!dialogResult)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
if (!dialogResult)
|
||||
{
|
||||
// User decided not to give access to locations permissions.
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Open permissions dialog.
|
||||
PermissionsService.OpenAppSettings();
|
||||
}
|
||||
}
|
||||
// Open permissions dialog.
|
||||
PermissionsService.OpenAppSettings();
|
||||
}
|
||||
}
|
||||
|
||||
// Location state
|
||||
if (Geolocation.IsGeolcationEnabled == false)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
// Location state
|
||||
if (Geolocation.IsGeolcationEnabled == false)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementLocationActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Bluetooth state
|
||||
if (await BluetoothService.GetBluetoothState() != BluetoothState.On)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementBluetoothActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
// Bluetooth state
|
||||
if (await BluetoothService.GetBluetoothState() != BluetoothState.On)
|
||||
{
|
||||
await ViewService.DisplayAlert(
|
||||
AppResources.MessageTitleHint,
|
||||
AppResources.MessageBikesManagementBluetoothActivation,
|
||||
AppResources.MessageAnswerOk);
|
||||
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
BikeCollection.Update(bikesOccupied.Response, Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Connect to bluetooth devices.
|
||||
ActionText = AppResources.ActivityTextSearchBikes;
|
||||
IEnumerable<LockInfoTdo> locksInfoTdo;
|
||||
try
|
||||
{
|
||||
locksInfoTdo = await LockService.GetLocksStateAsync(
|
||||
lockIdList.Select(x => x.ToLockInfoTdo()).ToList(),
|
||||
LockService.TimeOut.MultiConnect);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext<MyBikesPageViewModel>().Error("Getting bluetooth state failed. {Exception}", exception);
|
||||
locksInfoTdo = new List<LockInfoTdo>();
|
||||
}
|
||||
// Connect to bluetooth devices.
|
||||
ActionText = AppResources.ActivityTextSearchBikes;
|
||||
IEnumerable<LockInfoTdo> locksInfoTdo;
|
||||
try
|
||||
{
|
||||
locksInfoTdo = await LockService.GetLocksStateAsync(
|
||||
lockIdList.Select(x => x.ToLockInfoTdo()).ToList(),
|
||||
LockService.TimeOut.MultiConnect);
|
||||
}
|
||||
catch (Exception exception)
|
||||
{
|
||||
Log.ForContext<MyBikesPageViewModel>().Error("Getting bluetooth state failed. {Exception}", exception);
|
||||
locksInfoTdo = new List<LockInfoTdo>();
|
||||
}
|
||||
|
||||
var locksInfo = lockIdList.UpdateById(locksInfoTdo);
|
||||
var locksInfo = lockIdList.UpdateById(locksInfoTdo);
|
||||
|
||||
BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo), Stations);
|
||||
BikeCollection.Update(bikesOccupied.Response.UpdateLockInfo(locksInfo), Stations);
|
||||
|
||||
await OnAppearing(() => UpdateTask());
|
||||
await OnAppearing(() => UpdateTask());
|
||||
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
}
|
||||
ActionText = "";
|
||||
IsIdle = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// True if any action can be performed (request and cancel request)
|
||||
/// </summary>
|
||||
public override bool IsIdle
|
||||
{
|
||||
get => base.IsIdle;
|
||||
set
|
||||
{
|
||||
if (value == base.IsIdle)
|
||||
return;
|
||||
/// <summary>
|
||||
/// True if any action can be performed (request and cancel request)
|
||||
/// </summary>
|
||||
public override bool IsIdle
|
||||
{
|
||||
get => base.IsIdle;
|
||||
set
|
||||
{
|
||||
if (value == base.IsIdle)
|
||||
return;
|
||||
|
||||
Log.ForContext<BikesViewModel>().Debug($"Switch value of {nameof(IsIdle)} to {value}.");
|
||||
base.IsIdle = value;
|
||||
base.OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible)));
|
||||
base.OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText)));
|
||||
}
|
||||
}
|
||||
Log.ForContext<BikesViewModel>().Debug($"Switch value of {nameof(IsIdle)} to {value}.");
|
||||
base.IsIdle = value;
|
||||
base.OnPropertyChanged(new PropertyChangedEventArgs(nameof(IsNoBikesOccupiedVisible)));
|
||||
base.OnPropertyChanged(new PropertyChangedEventArgs(nameof(NoBikesOccupiedText)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Create task which updates my bike view model.</summary>
|
||||
private void UpdateTask()
|
||||
{
|
||||
// Start task which periodically updates pins.
|
||||
PostAction(
|
||||
unused =>
|
||||
{
|
||||
ActionText = AppResources.ActivityTextUpdating;
|
||||
IsConnected = IsConnectedDelegate();
|
||||
},
|
||||
null);
|
||||
/// <summary> Create task which updates my bike view model.</summary>
|
||||
private void UpdateTask()
|
||||
{
|
||||
// Start task which periodically updates pins.
|
||||
PostAction(
|
||||
unused =>
|
||||
{
|
||||
ActionText = AppResources.ActivityTextUpdating;
|
||||
IsConnected = IsConnectedDelegate();
|
||||
},
|
||||
null);
|
||||
|
||||
var result = ConnectorFactory(IsConnected).Query.GetBikesOccupiedAsync().Result;
|
||||
var result = ConnectorFactory(IsConnected).Query.GetBikesOccupiedAsync().Result;
|
||||
|
||||
var bikes = result.Response;
|
||||
var bikes = result.Response;
|
||||
|
||||
var exception = result.Exception;
|
||||
if (exception != null)
|
||||
{
|
||||
Log.ForContext<MyBikesPageViewModel>().Error("Getting bikes occupied in polling context failed with exception {Exception}.", exception);
|
||||
}
|
||||
var exception = result.Exception;
|
||||
if (exception != null)
|
||||
{
|
||||
Log.ForContext<MyBikesPageViewModel>().Error("Getting bikes occupied in polling context failed with exception {Exception}.", exception);
|
||||
}
|
||||
|
||||
PostAction(
|
||||
unused =>
|
||||
{
|
||||
BikeCollection.Update(bikes, Stations); // Updating collection leads to update of GUI.
|
||||
Exception = result.Exception;
|
||||
ActionText = string.Empty;
|
||||
},
|
||||
null);
|
||||
}
|
||||
}
|
||||
PostAction(
|
||||
unused =>
|
||||
{
|
||||
BikeCollection.Update(bikes, Stations); // Updating collection leads to update of GUI.
|
||||
Exception = result.Exception;
|
||||
ActionText = string.Empty;
|
||||
},
|
||||
null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue