mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge
synced 2024-08-15 03:40:31 +02:00
Fix wind speed and direction not being paceled
This also introduces a version to check befor unpaceling.
This commit is contained in:
parent
ef7c00a7df
commit
e57025cd82
@ -15,6 +15,7 @@
|
||||
|
||||
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/>. */
|
||||
|
||||
package nodomain.freeyourgadget.gadgetbridge.model;
|
||||
|
||||
import android.os.Parcel;
|
||||
@ -35,6 +36,7 @@ public class WeatherSpec implements Parcelable {
|
||||
return new WeatherSpec[size];
|
||||
}
|
||||
};
|
||||
public static final int VERSION = 2;
|
||||
public int timestamp;
|
||||
public String location;
|
||||
public int currentTemp;
|
||||
@ -53,15 +55,20 @@ public class WeatherSpec implements Parcelable {
|
||||
}
|
||||
|
||||
protected WeatherSpec(Parcel in) {
|
||||
timestamp = in.readInt();
|
||||
location = in.readString();
|
||||
currentTemp = in.readInt();
|
||||
currentConditionCode = in.readInt();
|
||||
currentCondition = in.readString();
|
||||
currentHumidity = in.readInt();
|
||||
todayMaxTemp = in.readInt();
|
||||
todayMinTemp = in.readInt();
|
||||
in.readList(forecasts, Forecast.class.getClassLoader());
|
||||
int version = in.readInt();
|
||||
if (version == VERSION) {
|
||||
timestamp = in.readInt();
|
||||
location = in.readString();
|
||||
currentTemp = in.readInt();
|
||||
currentConditionCode = in.readInt();
|
||||
currentCondition = in.readString();
|
||||
currentHumidity = in.readInt();
|
||||
todayMaxTemp = in.readInt();
|
||||
todayMinTemp = in.readInt();
|
||||
windSpeed = in.readFloat();
|
||||
windDirection = in.readInt();
|
||||
in.readList(forecasts, Forecast.class.getClassLoader());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,6 +78,7 @@ public class WeatherSpec implements Parcelable {
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeInt(VERSION);
|
||||
dest.writeInt(timestamp);
|
||||
dest.writeString(location);
|
||||
dest.writeInt(currentTemp);
|
||||
@ -79,6 +87,8 @@ public class WeatherSpec implements Parcelable {
|
||||
dest.writeInt(currentHumidity);
|
||||
dest.writeInt(todayMaxTemp);
|
||||
dest.writeInt(todayMinTemp);
|
||||
dest.writeFloat(windSpeed);
|
||||
dest.writeInt(windDirection);
|
||||
dest.writeList(forecasts);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user