コード例 #1
0
ファイル: MainActivity.cs プロジェクト: essieM/WeatherApp
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            //Initialize the views
            tvDate      = FindViewById <TextView>(Resource.Id.tv_date);
            tvDate.Text = string.Format("TODAY, {0}", DateTime.Today.ToString("dd MMMMM yyyy"));

            tvMaxTemp      = FindViewById <TextView>(Resource.Id.tv_maxTemperature);
            tvMaxTemp.Text = string.Format("max 0\u00B0C ");

            tvMinTemp      = FindViewById <TextView>(Resource.Id.tv_minTemperature);
            tvMinTemp.Text = string.Format("min 0\u00B0C ");

            tvCity = FindViewById <TextView>(Resource.Id.tv_city);

            weatherViewModel = new WeatherViewModel();

            UserDialogs.Init(this);

            UserDialogs.Instance.ShowLoading("Loading data...");

            var data = Task.Run(async() =>
            {
                //Fetch the weather forecast for the day from the weather service
                await weatherViewModel.GetWeatherForecast();
                UpdateFields();
            });

            UserDialogs.Instance.HideLoading();
        }
コード例 #2
0
        public override async void ViewWillAppear(bool animated)
        {
            base.ViewWillAppear(animated);

            loadingOverlay = new LoadingOverlay(UIScreen.MainScreen.Bounds, "Loading data...");
            View.AddSubview(loadingOverlay);

            await weatherViewModel.GetWeatherForecast();

            loadingOverlay.Hide();

            UpdateFields();
        }
コード例 #3
0
        public JsonResult GetWeather()
        {
            WeatherViewModel weather = new WeatherViewModel();

            return(Json(weather.GetWeatherForecast(), JsonRequestBehavior.AllowGet));
        }