use of nodomain.freeyourgadget.gadgetbridge.model.Weather in project Gadgetbridge by Freeyourgadget.
the class WeatherNotificationReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction() == null || !intent.getAction().contains("WEATHER_UPDATE_2")) {
LOG.info("Wrong action");
return;
}
ParcelableWeather2 parcelableWeather2 = null;
try {
parcelableWeather2 = intent.getParcelableExtra("ru.gelin.android.weather.notification.EXTRA_WEATHER");
} catch (RuntimeException e) {
LOG.error("cannot get ParcelableWeather2", e);
}
if (parcelableWeather2 != null) {
Weather weather = Weather.getInstance();
weather.setReconstructedOWMForecast(parcelableWeather2.reconstructedOWMForecast);
WeatherSpec weatherSpec = parcelableWeather2.weatherSpec;
LOG.info("weather in " + weatherSpec.location + " is " + weatherSpec.currentCondition + " (" + (weatherSpec.currentTemp - 273) + "°C)");
Weather.getInstance().setWeatherSpec(weatherSpec);
GBApplication.deviceService().onSendWeather(weatherSpec);
}
}
Aggregations