Search in sources :

Example 1 with Weather

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);
    }
}
Also used : Weather(nodomain.freeyourgadget.gadgetbridge.model.Weather) ParcelableWeather2(ru.gelin.android.weather.notification.ParcelableWeather2) WeatherSpec(nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec)

Aggregations

Weather (nodomain.freeyourgadget.gadgetbridge.model.Weather)1 WeatherSpec (nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec)1 ParcelableWeather2 (ru.gelin.android.weather.notification.ParcelableWeather2)1