private void App_SeekiosChanged(object sender, int e) { InvokeOnMainThread(() => { _seekiosSelected = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.UIdSeekios == App.Locator.DetailSeekios.SeekiosSelected.UIdSeekios); if (_seekiosSelected.LastKnownLocation_latitude == App.DefaultLatitude && _seekiosSelected.LastKnownLocation_longitude == App.DefaultLongitude) { _firstInitialise = true; } else { _firstInitialise = false; } if (_firstInitialise) { _firstInitialise = false; Tableview.Source = new DetailSeekiosSource(this, _seekiosSelected); Tableview.ReloadData(); if (_seekiosSelected.LastKnownLocation_dateLocationCreation.HasValue && _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.Year != 1) { SeekiosLastPositionLabel.Text = _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow(); } else { Tableview.ScrollToRow(NSIndexPath.FromRowSection(0, 0) , UITableViewScrollPosition.Top, false); SeekiosLastPositionLabel.Text = Application.LocalizedString("NoPosition"); } } SetDataAndStyleToView(); UpdateBatteryView(); }); }
private void InitializeSeekiosInformation() { // Seekios picture if (string.IsNullOrEmpty(_seekiosSelected.SeekiosPicture)) { SeekiosImageView.Image = UIImage.FromBundle("DefaultSeekios"); } else { using (var dataDecoded = new NSData(_seekiosSelected.SeekiosPicture , NSDataBase64DecodingOptions.IgnoreUnknownCharacters)) { SeekiosImageView.Image = new UIImage(dataDecoded); } } // Seekios name SeekiosNameLabel.Text = _seekiosSelected.SeekiosName; // Seekios need update ? if (App.CurrentUserEnvironment.LastVersionEmbedded != null && _seekiosSelected.VersionEmbedded_idversionEmbedded != App.CurrentUserEnvironment.LastVersionEmbedded.IdVersionEmbedded && !App.CurrentUserEnvironment.LastVersionEmbedded.IsBetaVersion) { if (_seekiosSelected.IsInPowerSaving) { using (var constraintY = NSLayoutConstraint.Create(NeedUpdateButton , NSLayoutAttribute.CenterY , NSLayoutRelation.Equal , SeekiosImageView , NSLayoutAttribute.CenterY , 1, 3)) { constraintY.Active = true; NSLayoutConstraint.ActivateConstraints(new NSLayoutConstraint[] { constraintY }); } } NeedUpdateButton.Hidden = false; } // Display or not power saving picture if (_seekiosSelected.IsInPowerSaving) { PowerSavingImage.Hidden = false; } else { PowerSavingImage.Hidden = true; } // Seekios last position if (_firstInitialise) { Tableview.ScrollToRow(NSIndexPath.FromRowSection(0, 0), UITableViewScrollPosition.Top, false); // Display statement to say there is no position SeekiosLastPositionLabel.Text = Application.LocalizedString("FirstPosition"); } else { if (_seekiosSelected.LastKnownLocation_dateLocationCreation.HasValue && _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.Year != 1) { if (_seekiosSelected.IsOnDemand) { // Display on refresh state (OnDemand) var textToDisplay = Application.LocalizedString("RefreshPosition"); var _seekiosOnDemand = App.Locator.Map.LsSeekiosOnDemand.FirstOrDefault(x => x.Seekios.Idseekios == _seekiosSelected.Idseekios); if (_seekiosOnDemand != null) { int minutes = (int)_seekiosOnDemand.Timer.CountDown / 60; int seconds = (int)_seekiosOnDemand.Timer.CountDown - (minutes * 60); SeekiosLastPositionLabel.Text = textToDisplay + string.Format(" {00:00}:{01:00}", minutes, seconds); _seekiosOnDemand.Timer.UpdateUI = () => { minutes = (int)_seekiosOnDemand.Timer.CountDown / 60; seconds = (int)_seekiosOnDemand.Timer.CountDown - (minutes * 60); SeekiosLastPositionLabel.Text = textToDisplay + string.Format(" {00:00}:{01:00}", minutes, seconds); }; // Hidden the count down, specific UI when it's the first location _seekiosOnDemand.Timer.Stopped = () => { SeekiosLastPositionLabel.Text = App.CurrentUserEnvironment.LsSeekios.FirstOrDefault(f => f.UIdSeekios == App.Locator.DetailSeekios.SeekiosSelected.UIdSeekios).LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow(); }; } else { SeekiosLastPositionLabel.Text = Application.LocalizedString("RefreshPosition"); } } else { // Display date of the last position SeekiosLastPositionLabel.Text = _seekiosSelected.LastKnownLocation_dateLocationCreation.Value.FormatDateFromNow(); } } else { // Display no position Tableview.ScrollToRow(NSIndexPath.FromRowSection(0, 0), UITableViewScrollPosition.Top, false); SeekiosLastPositionLabel.Text = Application.LocalizedString("NoPosition"); } } }