Exemple #1
0
        public async Task <bool> RefreshWeatherAsync()
        {
            try
            {
                var location = await LocationUtil.GetLocationAsync(Settings);

                // Couldn't get user's location
                if (location.Name == Common.GetLocalizedText("WeatherMapPinUnknownLabel"))
                {
                    ErrorTitle    = Common.GetLocalizedText("LocationErrorTitle");
                    ErrorSubtitle = Common.GetLocalizedText("LocationErrorSubtitle");
                    return(false);
                }

                var weather = await WeatherProvider.Instance.GetGenericWeatherAsync(
                    location.Position.Latitude,
                    location.Position.Longitude
                    );

                // Couldn't get weather
                if (weather == null)
                {
                    ErrorTitle    = Common.GetLocalizedText("GenericErrorTitle");
                    ErrorSubtitle = Common.GetLocalizedText("WeatherErrorSubtitle");
                    return(false);
                }

                DisplayWeather(weather);

                _currentWeather = weather;

                return(true);
            }
            catch (Exception ex)
            {
                LogService.WriteException(ex);
                return(false);
            }
        }