mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-10 17:11:56 +01:00
Garmin: Fix daily weather missing current day
This commit is contained in:
parent
c04d3adf7c
commit
bd5b54c3b4
@ -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;
|
||||
|
@ -57,7 +57,8 @@ public class WeatherHandler {
|
||||
final List<WeatherForecastDay> 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));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user