I am using Cloud Firestore as my Database and in every document there is a Map named restaurant_info that has as it typically stores <"name","Name of The Restaurant">, <"Location",GEOPoint of the Restaurant> and some more fields. The problem is the Geo Point class doesn't implement Parcelable or Serializable interface.
There are two ways in which you can solve this. The first one would be to add to your Restaurant
class that implements the Parcelable
interface:
class Restaurant implements Parcelable {}
And then override writeToParcel()
method and create another constructor like this:
private GeoPoint geoPoint;
@Override
public void writeToParcel(Parcel parcel, int i) {
parcel.writeDouble(geoPoint.getLatitude());
parcel.writeDouble(geoPoint.getLongitude());
}
public Restaurant(Parcel in) {
Double lat = in.readDouble();
Double lng = in.readDouble();
geoPoint = new GeoPoint(lat, lng);
}
The second approach would be to store the lat
and long
in your Restaurant
class as double primitves and everytime you need a GeoPoint object, create it like this:
GeoPoint geoPoint = new GeoPoint(restaurant.getLatitude(), restaurant.getLongitudeE6());
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With