protected virtual void UpdateWeatherPart(Context context, RemoteViews view, AppWidgetSettings settings, bool isDemoMode) { var weather = settings.Weather; var utcNow = DateTime.UtcNow; if (isDemoMode && weather == null) { var weatherDataPoint = new WeatherDataPoint { Date = utcNow, Temperature = 0, MinTemperature = -1, MaxTemperature = 1, WeatherCode = WeatherCodes.ClearSky, Condition = context.GetString(Resource.String.DemoCondition) }; weather = new WeatherForecast(providerId: settings.WeatherProviderId, latitude: null, longitude: null, units: AppSettings.Default.Units, languageCode: AppSettings.Default.Language, link: null, hasIcons: false) { Currently = weatherDataPoint, Daily = new[] { weatherDataPoint } }; } if (weather?.MaxPublishedDate == null) { return; } var actualUtcDate = utcNow > weather.MaxPublishedDate ? weather.MaxPublishedDate.Value : utcNow; var currently = weather.FindActualCurrentlyAsync(actualUtcDate).Result; if (currently == null) { return; } var temperature = string.Empty; using (var weatherTools = new WeatherTools { ProviderUnits = weather.Units, }) { var degree = weatherTools.DegreeString; if (currently.Temperature.HasValue) { temperature = weatherTools.ConvertTemperatureToString(currently.Temperature.Value, "{0:f0}{1}", degree); } SetTextFormatted(view, Resource.Id.txtTemp, temperature, weatherTools.IsTemperatureAlerted(currently.Temperature)); var minTempText = string.Empty; var maxTempText = string.Empty; var visibility = ViewStates.Gone; var minTemp = weatherTools .CalculateMinTemperatureAsync(actualUtcDate, weather, currently.MinTemperature).Result; var maxTemp = weatherTools .CalculateMaxTemperatureAsync(actualUtcDate, weather, currently.MaxTemperature).Result; if (minTemp.HasValue && maxTemp.HasValue) { minTempText = weatherTools.ConvertTemperatureToString(minTemp.Value, "{0:f0}{1}", degree); maxTempText = weatherTools.ConvertTemperatureToString(maxTemp.Value, "{0:f0}{1}", degree); visibility = ViewStates.Visible; } SetTextFormatted(view, Resource.Id.txtLow, minTempText, weatherTools.IsTemperatureAlerted(minTemp)); view.SetViewVisibility(Resource.Id.txtLowIndicator, visibility); SetTextFormatted(view, Resource.Id.txtHigh, maxTempText, weatherTools.IsTemperatureAlerted(maxTemp)); view.SetViewVisibility(Resource.Id.txtHighIndicator, visibility); var conditionIconId = weatherTools.GetConditionIconId(WidgetTypes.AppWidget, settings.WidgetIconStyle, currently, true, true); view.SetImageViewResource(Resource.Id.imgCondition, conditionIconId); //"Небольшой снегопад " SetTextFormatted(view, Resource.Id.txtCondition, (currently.Condition ?? string.Empty).Trim().ToCapital(), weatherTools.IsConditionExtreme(currently.WeatherCode)); } var locality = (settings.LocationAddress?.GetDisplayLocality() ?? string.Empty).Trim(); if (string.IsNullOrEmpty(locality) && isDemoMode) { locality = context.GetString(settings.UseTrackCurrentLocation ? Resource.String.CurrentLocationEmpty : Resource.String.DemoLocality); } view.SetTextViewText(Resource.Id.txtLocation, locality); }