1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-10-18 17:29:35 +02:00

Fix wind speed and direction not being paceled

This also introduces a version to check befor unpaceling.
This commit is contained in:
Andreas Shimokawa 2020-10-01 13:56:03 +02:00
parent ef7c00a7df
commit e57025cd82

View File

@ -15,6 +15,7 @@
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */ along with this program. If not, see <http://www.gnu.org/licenses/>. */
package nodomain.freeyourgadget.gadgetbridge.model; package nodomain.freeyourgadget.gadgetbridge.model;
import android.os.Parcel; import android.os.Parcel;
@ -35,6 +36,7 @@ public class WeatherSpec implements Parcelable {
return new WeatherSpec[size]; return new WeatherSpec[size];
} }
}; };
public static final int VERSION = 2;
public int timestamp; public int timestamp;
public String location; public String location;
public int currentTemp; public int currentTemp;
@ -53,6 +55,8 @@ public class WeatherSpec implements Parcelable {
} }
protected WeatherSpec(Parcel in) { protected WeatherSpec(Parcel in) {
int version = in.readInt();
if (version == VERSION) {
timestamp = in.readInt(); timestamp = in.readInt();
location = in.readString(); location = in.readString();
currentTemp = in.readInt(); currentTemp = in.readInt();
@ -61,8 +65,11 @@ public class WeatherSpec implements Parcelable {
currentHumidity = in.readInt(); currentHumidity = in.readInt();
todayMaxTemp = in.readInt(); todayMaxTemp = in.readInt();
todayMinTemp = in.readInt(); todayMinTemp = in.readInt();
windSpeed = in.readFloat();
windDirection = in.readInt();
in.readList(forecasts, Forecast.class.getClassLoader()); in.readList(forecasts, Forecast.class.getClassLoader());
} }
}
@Override @Override
public int describeContents() { public int describeContents() {
@ -71,6 +78,7 @@ public class WeatherSpec implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(VERSION);
dest.writeInt(timestamp); dest.writeInt(timestamp);
dest.writeString(location); dest.writeString(location);
dest.writeInt(currentTemp); dest.writeInt(currentTemp);
@ -79,6 +87,8 @@ public class WeatherSpec implements Parcelable {
dest.writeInt(currentHumidity); dest.writeInt(currentHumidity);
dest.writeInt(todayMaxTemp); dest.writeInt(todayMaxTemp);
dest.writeInt(todayMinTemp); dest.writeInt(todayMinTemp);
dest.writeFloat(windSpeed);
dest.writeInt(windDirection);
dest.writeList(forecasts); dest.writeList(forecasts);
} }