예제 #1
0
 public async void LoadWeatherForecastAsync() // Runs to call and sets it into the parameter fields the response fetch from the URL through the RESThandler using the fields found from our class ResponseFC(Forecast Weather)
 {
     objRest = new RESThandler(@"http://api.openweathermap.org/data/2.5/forecast?lat=" + Convert.ToDouble(tvLat.Text) + "&lon=" + Convert.ToDouble(tvLong.Text) + "&type=accurate&mode=xml&units=metric&APPID=1f324d7043102d230f6b41b4781b2cfd");
     var ResponseFC = await objRest.ExecuteRequestAsyncFC();
     // Sunrise and Sunset for Current Weather
     tvSunRise.Text = ResponseFC.sun.rise.TimeOfDay.ToString();
     tvSunSet.Text = ResponseFC.sun.set.TimeOfDay.ToString();
     // Day 1
     tvDay1.Text = Convert.ToString(ResponseFC.forecast[1].from.DayOfWeek);            
     // Day 2
     tvDay2.Text = Convert.ToString(ResponseFC.forecast[9].from.DayOfWeek);
     string cloud2 = ResponseFC.forecast[9].symbol.var;
     Koush.UrlImageViewHelper.SetUrlDrawable(ivDay2Cloud, "http://openweathermap.org/img/w/" + cloud2 + ".png");
     Console.WriteLine("........................" + ResponseFC.forecast[9].clouds.value);  
     tvDay2Temperature.Text = Convert.ToString(ResponseFC.forecast[9].temperature.value + "°");
     // Day 3
     tvDay3.Text = Convert.ToString(ResponseFC.forecast[16].from.DayOfWeek);
     string cloud3 = ResponseFC.forecast[16].symbol.var;
     Koush.UrlImageViewHelper.SetUrlDrawable(ivDay3Cloud, "http://openweathermap.org/img/w/" + cloud3 + ".png");           
     tvDay3Temperature.Text = Convert.ToString(ResponseFC.forecast[16].temperature.value + "°");
     // Day 4
     tvDay4.Text = Convert.ToString(ResponseFC.forecast[24].from.DayOfWeek);
     string cloud4 = ResponseFC.forecast[24].symbol.var;
     Koush.UrlImageViewHelper.SetUrlDrawable(ivDay4Cloud, "http://openweathermap.org/img/w/" + cloud4 + ".png");
     tvDay4Temperature.Text = Convert.ToString(ResponseFC.forecast[24].temperature.value + "°");
     // Day 5
     tvDay5.Text = Convert.ToString(ResponseFC.forecast[32].from.DayOfWeek);
     string cloud5 = ResponseFC.forecast[32].symbol.var;
     Koush.UrlImageViewHelper.SetUrlDrawable(ivDay5Cloud, "http://openweathermap.org/img/w/" + cloud5 + ".png");
     tvDay5Temperature.Text = Convert.ToString(ResponseFC.forecast[32].temperature.value + "°");
     Console.WriteLine("**************************" + ResponseFC.location.location.latitude);
     Console.WriteLine("**************************" + ResponseFC.location.location.longitude);            
 }
예제 #2
0
        public async void LoadTodaysWeatherAsync() // Runs to call and sets it into the parameter fields the response fetch from the URL through the RESThandler using the fields found from our class Response(CurrentWeather)
        {
            objRest = new RESThandler(@"http://api.openweathermap.org/data/2.5/weather?lat=" + Convert.ToDouble(tvLat.Text) + "&lon=" + Convert.ToDouble(tvLong.Text) + "&type=accurate&mode=xml&units=metric&APPID=1f324d7043102d230f6b41b4781b2cfd");
            var Response = await objRest.ExecuteRequestAsync();
            tvLocality.Text = Response.City.Name;
            string cloud = Response.Weather.Icon;
            Koush.UrlImageViewHelper.SetUrlDrawable(ivCloudIcon, "http://openweathermap.org/img/w/" + cloud + ".png");
            tvTemperature.Text = Response.Temperature.Value + "°";
            tvTempMin.Text = Response.Temperature.Min + "°";
            tvTempMax.Text = Response.Temperature.Max + "°";            
            tvHumidity.Text = Response.Humidity.Value + "%";
            tvPressure.Text = Response.Pressure.Value + "hPa";
            tvWindDirection.Text = Response.Wind.Direction.Code;
            
            string cloud1 = Response.Weather.Icon;
            Koush.UrlImageViewHelper.SetUrlDrawable(ivDay1Cloud, "http://openweathermap.org/img/w/" + cloud1 + ".png");
            tvDay1Temperature.Text = Convert.ToString(Response.Temperature.Value + "°");

        }