protected override void OnPostExecute(string result) { //Controls activity.txtZip = activity.FindViewById <TextView>(Resource.Id.txtZip); activity.txtLastUpdateZip = activity.FindViewById <TextView>(Resource.Id.txtLastUpdateZip); activity.txtDescriptionZip = activity.FindViewById <TextView>(Resource.Id.txtDescriptionZip); activity.txtHumidityZip = activity.FindViewById <TextView>(Resource.Id.txtHumidityZip); activity.txtTimeZip = activity.FindViewById <TextView>(Resource.Id.txtTimeZip); activity.txtCelsiusZip = activity.FindViewById <TextView>(Resource.Id.txtCelsiusZip); activity.imgViewZip = activity.FindViewById <ImageView>(Resource.Id.imageViewZip); try { base.OnPostExecute(result); if (result.Contains("Error: Not City Found")) { // pd.Dismiss(); activity.txtZip.Text = "Error: Not City Found"; return; } openWeatherMap = JsonConvert.DeserializeObject <OpenWeatherMap>(result); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Exception : " + ex.Message); activity.txtZip.Text = "Error: Not City Found "; return; } //pd.Dismiss(); //Add Data activity.txtZip.Text = $"{openWeatherMap.name},{openWeatherMap.sys.country}"; activity.txtLastUpdateZip.Text = $"Last Updated:{DateTime.Now.ToString("dd MMMM yyyy HH: mm ")}"; activity.txtDescriptionZip.Text = $"{openWeatherMap.weather[0].description}"; activity.txtHumidityZip.Text = $"Humidity:{ openWeatherMap.main.humidity} % "; activity.txtTimeZip.Text = $"{Common.Common.UnixTimeStampToDateTime(openWeatherMap.sys.sunrise).ToString("HH: mm")}/{Common.Common.UnixTimeStampToDateTime(openWeatherMap.sys.sunset).ToString("HH: mm ")}"; activity.txtCelsiusZip.Text = $"{openWeatherMap.main.temp} °C"; if (!string.IsNullOrEmpty(openWeatherMap.weather[0].icon)) { Picasso.With(activity.ApplicationContext).Load(Common.Common.GetImage(openWeatherMap.weather[0].icon)).Into(activity.imgViewZip); } }
public GetWeather(CityActivity activity, OpenWeatherMap openWeatherMap) { this.activity = activity; this.openWeatherMap = openWeatherMap; }