diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java index 10c6c8376..8a906f07c 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/model/WeatherSpec.java @@ -200,6 +200,30 @@ public class WeatherSpec implements Parcelable, Serializable { dest.writeList(hourly); } + /** + * Convert the current day's forecast to a {@link Daily} object. + */ + public Daily todayAsDaily() { + final Daily daily = new Daily(); + + daily.minTemp = this.todayMinTemp; + daily.maxTemp = this.todayMaxTemp; + daily.conditionCode = this.currentConditionCode; + daily.humidity = this.currentHumidity; + daily.windSpeed = this.windSpeed; + daily.windDirection = this.windDirection; + daily.uvIndex = this.uvIndex; + daily.precipProbability = this.precipProbability; + daily.sunRise = this.sunRise; + daily.sunSet = this.sunSet; + daily.moonRise = this.moonRise; + daily.moonSet = this.moonSet; + daily.moonPhase = this.moonPhase; + daily.airQuality = this.airQuality; + + return daily; + } + @Deprecated // kept for backwards compatibility with old weather apps public static class Forecast implements Parcelable, Serializable { private static final long serialVersionUID = 1L; diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/http/WeatherHandler.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/http/WeatherHandler.java index d219e2536..5c003b0c8 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/http/WeatherHandler.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/garmin/http/WeatherHandler.java @@ -57,7 +57,8 @@ public class WeatherHandler { final List ret = new ArrayList<>(duration); final GregorianCalendar date = new GregorianCalendar(); date.setTime(new Date(weatherSpec.timestamp * 1000L)); - for (int i = 0; i < Math.min(duration, weatherSpec.forecasts.size()); i++) { + ret.add(new WeatherForecastDay(date, weatherSpec.todayAsDaily(), tempUnit, speedUnit)); + for (int i = 0; i < Math.min(duration, weatherSpec.forecasts.size()) - 1; i++) { date.add(Calendar.DAY_OF_MONTH, 1); ret.add(new WeatherForecastDay(date, weatherSpec.forecasts.get(i), tempUnit, speedUnit)); }