Example #1
0
        private async void Button_Click(object sender, EventArgs e)
        {
            EditText getZip = FindViewById <EditText>(Resource.Id.theZipCode);

            Toast.MakeText(this, "Please wait while your City is found", ToastLength.Short).Show();
            if (!String.IsNullOrEmpty(getZip.Text))
            {
                Class newClass = await APICall.GetClass(getZip.Text); //call our API class where the magic happens!

                if (newClass != null)
                {
                    //set the returned data from the class to our text fields in our Main axml file
                    FindViewById <TextView>(Resource.Id.txtCity).Text        = newClass.Title;
                    FindViewById <TextView>(Resource.Id.txtMainWeather).Text = newClass.MainWeather;
                    FindViewById <TextView>(Resource.Id.txtDescription).Text = newClass.Description;
                    FindViewById <TextView>(Resource.Id.txtTemp).Text        = newClass.Temperature;
                    FindViewById <TextView>(Resource.Id.txtTempMin).Text     = newClass.Temp_min;
                    FindViewById <TextView>(Resource.Id.txtTempMax).Text     = newClass.Temp_max;
                    ImageView imgView = FindViewById <ImageView>(Resource.Id.imageView);
                    iconWebAddress = imageString + newClass.Icon + imgString2;
                    var image = GetImage(iconWebAddress);
                    imgView.SetImageBitmap(image);
                    currentCity = newClass.Title; //set our local variable to that of our Class Value. to be used later.
                }
            }
            else
            {
                Toast.MakeText(this, "You must enter a zip code", ToastLength.Short).Show();
            }
            currentZip  = getZip.Text;
            getZip.Text = "";
        }
Example #2
0
        private async void GetFavorite()
        {
            Class newClass = await APICall.GetClass(FavoriteList.favoriteZip.Trim());

            if (newClass != null)
            {
                //pretty much the same as main activity.
                FindViewById <TextView>(Resource.Id.favCity).Text        = newClass.Title;
                FindViewById <TextView>(Resource.Id.favMainWeather).Text = newClass.MainWeather;
                FindViewById <TextView>(Resource.Id.favDescription).Text = newClass.Description;
                FindViewById <TextView>(Resource.Id.favTemp).Text        = newClass.Temperature;
                FindViewById <TextView>(Resource.Id.favTempMin).Text     = newClass.Temp_min;
                FindViewById <TextView>(Resource.Id.favTempMax).Text     = newClass.Temp_max;
                ImageView iView = FindViewById <ImageView>(Resource.Id.favImageView);
                iconWebAddress = imageString + newClass.Icon + imgString2;
                var image = GetImage(iconWebAddress);
                iView.SetImageBitmap(image);
            }
        }