1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-12-25 18:15:49 +01:00

Pebble: push current weather to TimeStylePebble again when watchface gets started

This commit is contained in:
Andreas Shimokawa 2016-12-31 19:17:08 +01:00
parent 4e543d4b34
commit 984e639e97
3 changed files with 28 additions and 4 deletions

View File

@ -45,7 +45,7 @@ public class WeatherNotificationReceiver extends BroadcastReceiver {
weatherSpec.tomorrowConditionCode = weather.forecastConditionCode;
weatherSpec.tomorrowMaxTemp = weather.forecastHighTemp;
weatherSpec.tomorrowMinTemp = weather.forecastLowTemp;
Weather.getInstance().setWeatherSpec(weatherSpec);
GBApplication.deviceService().onSendWeather(weatherSpec);
}
}

View File

@ -4,8 +4,23 @@ import ru.gelin.android.weather.notification.ParcelableWeather2;
public class Weather {
private ParcelableWeather2 weather2 = null;
public ParcelableWeather2 getWeather2() {return weather2;}
public void setWeather2(ParcelableWeather2 weather2) {this.weather2 = weather2;}
private WeatherSpec weatherSpec = null;
public ParcelableWeather2 getWeather2() {
return weather2;
}
public void setWeather2(ParcelableWeather2 weather2) {
this.weather2 = weather2;
}
public WeatherSpec getWeatherSpec() {
return weatherSpec;
}
public void setWeatherSpec(WeatherSpec weatherSpec) {
this.weatherSpec = weatherSpec;
}
private static final Weather weather = new Weather();
public static Weather getInstance() {return weather;}

View File

@ -10,6 +10,7 @@ import java.util.UUID;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEvent;
import nodomain.freeyourgadget.gadgetbridge.deviceevents.GBDeviceEventSendBytes;
import nodomain.freeyourgadget.gadgetbridge.model.Weather;
import nodomain.freeyourgadget.gadgetbridge.model.WeatherSpec;
public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
@ -115,10 +116,18 @@ public class AppMessageHandlerTimeStylePebble extends AppMessageHandler {
@Override
public GBDeviceEvent[] handleMessage(ArrayList<Pair<Integer, Object>> pairs) {
// Just ACK
GBDeviceEventSendBytes sendBytesAck = new GBDeviceEventSendBytes();
sendBytesAck.encodedBytes = mPebbleProtocol.encodeApplicationMessageAck(mUUID, mPebbleProtocol.last_id);
return new GBDeviceEvent[]{sendBytesAck};
// TODO: trigger update of weather?
}
@Override
public GBDeviceEvent[] onAppStart() {
WeatherSpec weatherSpec = Weather.getInstance().getWeatherSpec();
GBDeviceEventSendBytes sendBytes = new GBDeviceEventSendBytes();
sendBytes.encodedBytes = encodeTimeStylePebbleWeather(weatherSpec);
return new GBDeviceEvent[]{sendBytes};
}
@Override