public async void BtnGetWeather_ClickAsync(object sender, System.EventArgs e) { cityName = etCity.Text.ToString(); if (etCity.Text.ToString().Length > 0) { progressBar.Visibility = ViewStates.Visible; WeatherService weatherService = new WeatherService(); var result = await weatherService.GetWeather(etCity.Text.ToString()); //WeatherInfo.RootObject weatherInfo = new WeatherInfo.RootObject(); //weatherInfo = result; if (result == null) { progressBar.Visibility = ViewStates.Invisible; Toast.MakeText(Application, "Cannot load data", ToastLength.Short).Show(); } else { progressBar.Visibility = ViewStates.Invisible; Intent weather_details = new Intent(this, typeof(WeatherDetailsActivity)); weather_details.PutExtra("DATA", JsonConvert.SerializeObject(result)); StartActivity(weather_details); } } else { Toast.MakeText(Application, "Please type a city name", ToastLength.Short).Show(); } }
private static Current getWeatherXML() { Current current = new Current(); WeatherService <Current> weatherService = new WeatherService <Current>(); current = weatherService.GetWeather(true); return(current); }
private static RootObject getWeatherJSON() { RootObject rootObject = new RootObject(); WeatherService <RootObject> weatherService = new WeatherService <RootObject>(); rootObject = weatherService.GetWeather(false); return(rootObject); }
private void searchButton_Click(object sender, RoutedEventArgs e) { if (textBoxSearch.Text.Length == 0) { return; } if (textBoxSearch.Text == PlaceholderSearch) { return; } WeatherResult wr = WeatherService.GetWeather(textBoxSearch.Text); if (wr != null) { labelCityNameZip.Content = wr.cityState + " " + wr.zipCode; labelCityLatLong.Content = "Latitude/Longitude: " + wr.latitude + "/" + wr.longitude; labelWeatherCondition.Content = wr.weather; labelElevation.Content = "Elevation: " + wr.elevation; labelLastUpdated.Content = wr.lastUpdated; labelTemperature.Content = "Temperature: " + wr.temperature; labelFeelsLike.Content = "Feels Like: " + wr.feelsLike; labelWind.Content = "Wind: " + wr.wind; labelWindDirection.Content = "Wind Direction: " + wr.windDirection; labelHumidity.Content = "Humidity: " + wr.humidity; labelVisibility.Content = "Visibility: " + wr.visibility; labelUV.Content = "UV: " + wr.uv; labelPrecipitation.Content = "Precipitation: " + wr.precipitation; setWeatherImage(wr.iconURL, wr.icon); } }