NielsMasdorp / Speculum-Android

[Not maintained] Android application powering a magic mirror.
MIT License
330 stars 71 forks source link

Alot of cities cannot be found via setup search #45

Closed StefanKrulj closed 7 years ago

StefanKrulj commented 7 years ago

Thus leaving you with a blank weather forecast. This include capitals like Copenhagen, Berlin etc. I have been scouring the code for the url insertion to use hardcoded forecast.io/darksky url/coordinates, but I am strugling to find where you do this.

gijsdewit commented 7 years ago

Hi, had this problem myself a couple of days ago. It's due to the fact that cities outside of the US (afaik) don't feature the visibility attribute. So when it gets the forecast for a city outside of the US, there's no visiblity attribute in the JSON response and the visibility attribute becomes "null". This causes the request to fail and keeps the app from showing the weather data.

I made a quick fix by adding a line that checks if it's "null" and than replaces it with an "unknown" String.

String visibilityInfo = response.getCurrently().getVisibility() != null response.getCurrently().getVisibility().intValue() + distanceUnit: "unknown";

Add this to the getCurrentWeather method in the ForecastIOService class and change:

.visibilityInfo(response.getCurrently().getVisibility().intValue() + distanceUnit)

to:

.visibilityInfo(visibilityInfo)

in the WeatherBuilder in the return statement of that method.

Ideally all attributes should be checked for "null".

Hope this fixes your problem.

StefanKrulj commented 7 years ago

Fixed it indeed! Thanks!

I have hidden those weather UI elements on my build (small tablet) so didnt even think to check the JSON response if those attributes were incorrect...

muude commented 7 years ago

Sorry, I may be a noob on this - but where should I make this change?

As OP writes, I am trying to choose Copenhagen, but with no luck.