A list of runpoints gets saved into sharedpreferences and should be retrieved later. All data, except the list of type PointF and two parameters "start" & "end" (both of type PointF) are correctly retrieved. Every point is retrieved as PointF(0,0), while the actual data is PointF(139000.0, 455000.0)
Result:
runpoint save: PointF(139000.0, 455000.0)
runpoint load: PointF(0.0, 0.0)
To save the runpoints I use JsonConvert.SerializeObject. I've found on other issues, the solution was to provide JsonSerializerSettings and set TypeNameHandling to All. However this did not make a difference for the result.
Both my Saving and Loading Code are provided. Below you'll find the blueprint for my TrackSpec class:
//Saving
TrackSpec activeTrack = runView.getTrack();
ISharedPreferences sharedPrefs = PreferenceManager.GetDefaultSharedPreferences(this);
ISharedPreferencesEditor editor = sharedPrefs.Edit();
for (int i = 0; i < activeTrack.path.Count; i++)
{
Console.WriteLine("runpoint save: " + activeTrack.path[i].point);
}
JsonSerializerSettings serializeSettings = new JsonSerializerSettings { TypeNameHandling = TypeNameHandling.All };
string toSave = JsonConvert.SerializeObject(activeTrack, Formatting.Indented, serializeSettings);
editor.PutString(routeNameInput, toSave);
editor.Apply();
//Load
ISharedPreferences sharedPrefs = PreferenceManager.GetDefaultSharedPreferences(this);
string json = sharedPrefs.GetString(routeName, "default");
TrackSpec trackObj = JsonConvert.DeserializeObject<TrackSpec>(json, serializeSettings);
for (int i = 0; i < trackObj.path.Count; i++)
{
Console.WriteLine("runpoint load: " + trackObj.path[i].point);
}
runView.setTrack(trackObj);
TrackSpec:
public class TrackSpec
{
public string routeName;
public List<TimeGeoPoint> path;
public float distance;
public string pace;
public float speed;
public PointF start;
public PointF end;
public DateTime date;
public TrackSpec(string routeName, List<TimeGeoPoint> path, float distance, string pace, float speed, PointF start, PointF end, DateTime date)
{
this.routeName = routeName;
this.path = path;
this.distance = distance;
this.pace = pace;
this.speed = speed;
this.start = start;
this.end = end;
this.date = date;
}
}