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 6838be8aec47f01cd6ce7db62128025a93a9a2ab..dfe337897f02e3da3c402173101bce076a4790fb 100644 (file)
@@ -62,4 +62,7 @@ public class AltosFrequency {
                frequency = f;
                description = d;
        }
+       public AltosFrequency() {
+               this(0, null);
+       }
 }
index 0c388f1b813cee13133006b4e26fe4534500d122..c511332bac7a3c967ee348939f47db2a1ed010a9 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) {
                }