Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            _plist = NSUserDefaults.StandardUserDefaults;
            var startDateEpoch = _plist.DoubleForKey("startDate");
            var endDateEpoch   = _plist.DoubleForKey("endDate");

            if (startDateEpoch > 0.0 && endDateEpoch > 0.0)
            {
                _startTime = startDateEpoch.FromUnixTime();
                _endTime   = endDateEpoch.FromUnixTime();
            }
            else
            {
                _startTime = DateTime.Now.AddDays(-7);
                _endTime   = DateTime.Now.AddDays(2);
            }
            timeLabel.Text = $"{_startTime.ToShortDateString()}-{_endTime.ToShortDateString()}";



            InitializeActivityIndicator();
            TableSource.ViewController = this;
            menuButton.Clicked        += (sender, e) => this.RevealViewController().RevealToggleAnimated(true);
            View.AddGestureRecognizer(this.RevealViewController().PanGestureRecognizer);
            var appDelegate = UIApplication.SharedApplication.Delegate as AppDelegate;

            ActiveStation    = appDelegate.ActiveStation;
            tableView.Source = TableSource;

            locationManager.AuthorizationChanged += (sender, args) =>
            {
                Console.WriteLine("Authorization changed to: {0}", args.Status);
            };
            locationManager.RequestWhenInUseAuthorization();
            GetAnnotationOfStation();
            if (ActiveStation != null)
            {
                WeatherInformation.GetWeatherData(double.Parse(ActiveStation.Latitude), double.Parse(ActiveStation.Longitude),
                                                  (WeatherData data) =>
                {
                    data.IconName = data.GetWeatherIcon(data.Condition);
                    InvokeOnMainThread(() =>
                    {
                        UpdateUIWeatherInformation(data);
                    });
                });
                // GetWeatherData(double.Parse(ActiveStation.Latitude), double.Parse(ActiveStation.Longitude));
            }

            InitializeDatabase();
        }