Skip to content

Instantly share code, notes, and snippets.

@px-amaac
Last active August 29, 2015 14:06
Show Gist options
  • Save px-amaac/0de82d712d41bd74b6af to your computer and use it in GitHub Desktop.
Save px-amaac/0de82d712d41bd74b6af to your computer and use it in GitHub Desktop.
public class Location implements Parcelable{
@Expose
private Integer id;
@Expose
private Coords coords;
@Expose
private Double distance;
public Location(Parcel in) {
readFromParcel(in);
}
@Override public int describeContents() {
return 0;
}
@Override public void writeToParcel(Parcel dest, int flags) {
dest.writeValue(id);
dest.writeParcelable(coords, flags);
dest.writeValue(distance);
}
public void readFromParcel(Parcel in) {
id = (Integer) in.readValue(null);
coords = in.readParcelable(Coords.class.getClassLoader());
distance = (Double) in.readValue(null);
}
public static final Creator<Location> CREATOR = new Creator<Location>() {
@Override
public Location createFromParcel(Parcel source) {
return new Location(source);
}
@Override
public Location[] newArray(int size) {
return new Location[size];
}
};
public Integer getId() {
return id;
}
public Coords getCoords() {
return coords;
}
public Double getDistance() {
return distance;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment