2015-12-27 19:44:33 +01:00
|
|
|
package nodomain.freeyourgadget.gadgetbridge.externalevents;
|
|
|
|
|
|
|
|
import android.content.BroadcastReceiver;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.Intent;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
2015-12-28 20:55:59 +01:00
|
|
|
import ru.gelin.android.weather.notification.ParcelableWeather2;
|
|
|
|
|
2015-12-27 19:44:33 +01:00
|
|
|
|
2015-12-28 11:33:22 +01:00
|
|
|
public class WeatherNotificationReceiver extends BroadcastReceiver {
|
2015-12-27 19:44:33 +01:00
|
|
|
private static final Logger LOG = LoggerFactory.getLogger(WeatherNotificationReceiver.class);
|
2015-12-28 11:33:22 +01:00
|
|
|
|
2015-12-27 19:44:33 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onReceive(Context context, Intent intent) {
|
|
|
|
if (!intent.getAction().contains("WEATHER_UPDATE_2")) {
|
|
|
|
LOG.info("Wrong action");
|
|
|
|
return;
|
|
|
|
}
|
2015-12-28 20:55:59 +01:00
|
|
|
ParcelableWeather2 weather = null;
|
|
|
|
try {
|
|
|
|
weather = intent.getParcelableExtra("ru.gelin.android.weather.notification.EXTRA_WEATHER");
|
|
|
|
} catch (RuntimeException e) {
|
|
|
|
e.printStackTrace();
|
2015-12-28 11:33:22 +01:00
|
|
|
}
|
|
|
|
|
2015-12-28 20:55:59 +01:00
|
|
|
if (weather != null) {
|
|
|
|
LOG.info("weather in " + weather.location + " is " + (weather.currentTemp - 273) + "°C");
|
2015-12-28 11:33:22 +01:00
|
|
|
}
|
|
|
|
|
2015-12-27 19:44:33 +01:00
|
|
|
}
|
|
|
|
}
|