public async Task<object> ProcessData(Configuration.Configuration config) { await Task.Delay(100); // Maybe fetch from service? var hour = Factory.DateTimeFactory.Instance.Now.Hour; List<string> compliments = new List<string>(); if (hour >= 3 && hour < 12 && _complimentType != DayTime.Morning) { _complimentType = DayTime.Morning; compliments = new List<string>(config.DayTimeCompliments[_complimentType]); } else if (hour >= 12 && hour < 17 && _complimentType != DayTime.Afternoon) { _complimentType = DayTime.Afternoon; compliments = new List<string>(config.DayTimeCompliments[_complimentType]); } else if (hour >= 17 || hour < 3 && _complimentType != DayTime.Evening) { _complimentType = DayTime.Evening; compliments = new List<string>(config.DayTimeCompliments[_complimentType]); } return compliments; }
public void UpdateUI(Configuration.Configuration config, object data) { var compliments = data as List<string>; if (compliments != null && compliments.Count > 0) { Items = new List<string>(compliments); } }
public void UpdateUI(Configuration.Configuration config, object data) { var weather = data as Weather; if (weather != null) { this.BeaufortWindScale = weather.BeaufortWindScale; this.SunState = weather.SunState; this.SunStateTime = weather.SunStateTime; this.Temperature = weather.Temperature; this.WeatherIcon = weather.WeatherIcon; if (this.Forecasts.Count == weather.Forecasts.Count) { for (int i = 0; i < weather.Forecasts.Count; i++) { this.Forecasts[i].Update(weather.Forecasts[i]); } } else { double opacity = 1; this.Forecasts.Clear(); foreach (var item in weather.Forecasts) { this.Forecasts.Add(item); item.Opacity = opacity; opacity -= 0.155; } } if (this.ForecastDetails.Count == weather.ForecastDetails.Count) { for (int i = 0; i < weather.ForecastDetails.Count; i++) { this.ForecastDetails[i].Update(weather.ForecastDetails[i]); } } else { double opacity = 1; this.ForecastDetails.Clear(); foreach (var item in weather.ForecastDetails) { this.ForecastDetails.Add(item); item.Opacity = opacity; opacity -= 0.155; } } } }
public async Task<object> ProcessData(Configuration.Configuration config) { return await _weatherFactory.GetWeather(config); }
public void UpdateUI(Configuration.Configuration config, object data) { var filteredCalendarItems = data as List<CalendarItem>; if (filteredCalendarItems != null) { if (!CalendarFactory.CompareCalendarItemList(_CalendarItems, filteredCalendarItems)) { double opacity = 1; filteredCalendarItems.ForEach((A => { A.Opacity = opacity; opacity -= 1d / config.MaxCalendarItems; })); CalendarItems = new ObservableCollection<CalendarItem>(filteredCalendarItems); } } }
public async Task<object> ProcessData(Configuration.Configuration config) { List<CalendarItem> newCalendarItems = await _calendarFactory.GetFullCalendarList(config); var now = DateTimeFactory.Instance.Now; List<CalendarItem> filteredCalendarItems = new List<CalendarItem>(); foreach (var item in newCalendarItems) { var dt = item.Start; if (now < dt) { try { UpdateTime(item, now); filteredCalendarItems.Add(item); } catch (Exception ex) { Log.e(ex); } } } return new List<CalendarItem>(filteredCalendarItems.Take(config.MaxCalendarItems)); }