public async Task <CurrentObservation> GetConditions() { if (DateTime.UtcNow - lastUpdate > TimeSpan.FromMinutes(5)) { lastUpdate = DateTime.UtcNow; var cond = await client.GetConditionsAsync(QueryType.GPS, new QueryOptions() { Latitude = lat, Longitude = lon, }); _conditions = cond.CurrentObservation; } return(_conditions); }
private string ParseResult(Weather weather) { if (weather.current_observation != null) { CurrentObservation o = weather.current_observation; DisplayLocation d = o.display_location; string result = string.Format("Weather for {0}{1}: {2}, {3}", d.full, (d.zip != null ? " (" + d.zip + ")" : ""), o.weather, o.temperature_string); result += string.Format("; feels like {0}. {1} winds. {2} humidity", o.feelslike_string, o.wind_string, o.relative_humidity); if (o.precip_today_metric != null) { result += string.Format("; {0} precipitation today", o.precip_today_string); } return(string.Format("{0}. {1}\n{2}", result, o.observation_time, o.forecast_url)); } return(null); }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { view = inflater.Inflate(Resource.Layout.CurrentConditionsFragment, container, false); ((MainActivity)this.Activity).StartProgressIndicator(); Task.Run(async() => { if (currentConditions == null) { currentConditions = await WeatherService.Instance.GetCurrentConditions(); } if (currentConditions != null) { this.Activity.RunOnUiThread(() => { var iconImage = view.FindViewById <ImageViewAsync>(Resource.Id.currentConditionIconImage); ImageService.Instance.LoadUrl(currentConditions.IconUrl).IntoAsync(iconImage); view.FindViewById <TextView>(Resource.Id.currentConditionsText).Text = currentConditions.Weather; view.FindViewById <TextView>(Resource.Id.temperatureText).Text = currentConditions.Temperature; view.FindViewById <TextView>(Resource.Id.feelsLikeText).Text = currentConditions.FeelsLike; view.FindViewById <TextView>(Resource.Id.windText).Text = currentConditions.WindDescription; view.FindViewById <TextView>(Resource.Id.windChillText).Text = currentConditions.Windchill; view.FindViewById <TextView>(Resource.Id.humidityText).Text = currentConditions.RelativeHumidity; view.FindViewById <TextView>(Resource.Id.dewpointText).Text = currentConditions.Dewpoint; view.FindViewById <TextView>(Resource.Id.heatIndexText).Text = currentConditions.HeatIndex; }); } ((MainActivity)this.Activity).StopProgressIndicator(); }); return(view); }
public static double Gust(this CurrentObservation observation, SpeedUnits units, bool round = false) => getValueInUnits(units, observation?.wind_gust_mph, observation?.wind_gust_kph, round);
public static double DewPoint(this CurrentObservation observation, TemperatureUnits units, bool round = false) => getValueInUnits(units, observation?.dewpoint_f, observation?.dewpoint_c, round);
public static double FeelsLike(this CurrentObservation observation, TemperatureUnits units, bool round = false) => getValueInUnits(units, observation?.feelslike_f, observation?.feelslike_c, round);
public static double Temp(this CurrentObservation observation, TemperatureUnits units, bool round = false) => getValueInUnits(units, observation?.temp_f, observation?.temp_c, round);
public static string VisibilityString(this CurrentObservation observation, DistanceUnits units, bool round = false) => getValueStringInUnits(observation.Visibility(units, round), units);
public static string PressureString(this CurrentObservation observation, PressureUnits units, bool round = false) => getValueStringInUnits(observation.Pressure(units, round), units);
public static string PrecipTodayString(this CurrentObservation observation, LengthUnits units, bool round = false) => getValueStringInUnits(observation.PrecipToday(units, round), units);
public static string GustString(this CurrentObservation observation, SpeedUnits units, bool round = false) => getWindString(observation.Gust(units, round), observation.wind_dir, units);
public static string DewPointString(this CurrentObservation observation, TemperatureUnits units, bool round = false, bool degreeSymbol = false) => getTemperatureString(observation.DewPoint(units, round), degreeSymbol);
public static double Visibility(this CurrentObservation observation, DistanceUnits units, bool round = false) => getValueInUnits(units, observation?.visibility_mi, observation?.visibility_km, round);
public static double Pressure(this CurrentObservation observation, PressureUnits units, bool round = false) => getValueInUnits(units, observation?.pressure_in, observation?.pressure_mb, round);
public static double PrecipToday(this CurrentObservation observation, LengthUnits units, bool round = false) => getValueInUnits(units, observation?.precip_today_in, observation?.precip_today_metric, round);