From b13037fad0905c5933d1ff579122ba1357b02eea Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 12 May 2016 19:13:05 -0700 Subject: altoslib: Store common frequencies in library version-independent form Serializable Objects in java are very specific to the class being serialized. As we bump the name of the library on a regular basis to note API/ABI issues, this mean a saved a Serializable object in the preferences database will fail to load across library version upgrades. The saved tracker state and saved common frequencies were the only objects saved in this form; this patch adds infrastructure for writing objects in a version-independent form, and then adds support for saving frequencies in that form. Signed-off-by: Keith Packard --- altoslib/AltosFrequency.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'altoslib/AltosFrequency.java') diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index ef46bd67..88997152 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -58,8 +58,21 @@ public class AltosFrequency implements Serializable { return diff < 0.010; } + public AltosHashSet hashSet() { + AltosHashSet h = new AltosHashSet(); + + h.putDouble("frequency", frequency); + h.putString("description", description); + return h; + } + public AltosFrequency(double f, String d) { frequency = f; description = d; } + + public AltosFrequency(AltosHashSet h) { + frequency = h.getDouble("frequency", 0.0); + description = h.getString("description", ""); + } } -- cgit v1.2.3