survivingwithandroid / WeatherLib

Android Weather Library: android weather lib to develop weather based app fast and easily
http://survivingwithandroid.github.io/WeatherLib/
640 stars 170 forks source link

getCurrentCondition crash if unitSystem is not set #2

Closed emptyway closed 10 years ago

emptyway commented 10 years ago

Test Code:

 //Weather
        WeatherClient client = WeatherClientDefault.getInstance();
        client.init(getActivity().getApplicationContext());
        WeatherConfig config = new WeatherConfig(); // Default configuration
        IWeatherProvider provider;

        try {
            provider = WeatherProviderFactory.createProvider(new YahooProviderType(), config);
            client.setProvider(provider);

            client.getCurrentCondition("2306217", new WeatherClient.WeatherEventListener() {
...

error output

java.lang.NullPointerException
            at       com.survivingwithandroid.weather.lib.util.WeatherUtility.isMetric(WeatherUtility.java:46)
            at com.survivingwithandroid.weather.lib.provider.yahooweather.YahooWeatherProvider.getQueryCurrentWeatherURL(YahooWeatherProvider.java:263)
            at com.survivingwithandroid.weather.lib.WeatherClientDefault.getCurrentCondition(WeatherClientDefault.java:129)
            at com.test.onResume(WeatherListFragment.java:99)

if add this line works good

config.unitSystem = WeatherConfig.UNIT_SYSTEM.M;