altoslib: Fix freq preference loading
authorKeith Packard <keithp@keithp.com>
Mon, 28 Aug 2017 07:10:04 +0000 (00:10 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 28 Aug 2017 07:22:43 +0000 (00:22 -0700)
Allocate throw-away freq array to get the class pointer.
Add null-ary AltosFrequency constructor for JSON code.

Signed-off-by: Keith Packard <keithp@keithp.com>
altoslib/AltosFrequency.java
altoslib/AltosPreferences.java

index 6838be8..dfe3378 100644 (file)
@@ -62,4 +62,7 @@ public class AltosFrequency {
                frequency = f;
                description = d;
        }
+       public AltosFrequency() {
+               this(0, null);
+       }
 }
index 0c388f1..c511332 100644 (file)
@@ -139,7 +139,7 @@ public class AltosPreferences {
                try {
                        AltosJson json = AltosJson.fromString(backend.getString(frequenciesPreference,
                                                                                null));
-                       frequencies = (AltosFrequency[]) json.make(frequencies.getClass());
+                       frequencies = (AltosFrequency[]) json.make((new AltosFrequency[1]).getClass());
                } catch (Exception e) {
                }