/// <summary> /// Initializes the view model. /// </summary> /// <param name="properties">View model instance properties.</param> /// <param name="pageNavigation">Page navigation object.</param> /// <returns>The initialization task.</returns> public async Task Init(IDictionary <string, object> properties, INavigation pageMavigation) { this.properties = properties; AppPageNavigation = pageMavigation; heartRateMonitorModel = new HeartRateMonitorModel(); heartRateMonitorModel.HeartRateMonitorDataChanged += ModelOnHeartRateMonitorDataChanged; heartRateMonitorModel.HeartRateSensorNotSupported += ModelOnHeartRateSensorNotSupported; if (!await heartRateMonitorModel.CheckPrivileges()) { PrivilegeDeniedInfoCommand?.Execute(null); return; } heartRateMonitorModel.Init(); RestoreHeartRateLimitSliderValue(); }
/// <summary> /// Initializes the view model. /// </summary> /// <returns>The initialization task.</returns> public async Task Init() { _heartRateMonitorModel = new HeartRateMonitorModel(); _heartRateMonitorModel.HeartRateMonitorDataChanged += ModelOnHeartRateMonitorDataChanged; _heartRateMonitorModel.HeartRateSensorNotSupported += ModelOnHeartRateSensorNotSupported; if (!await _heartRateMonitorModel.CheckPrivileges()) { Device.StartTimer(TimeSpan.Zero, () => { PrivilegeDeniedInfoCommand?.Execute(null); // return false to run the timer callback only once return(false); }); return; } _heartRateMonitorModel.Init(); }