altoslib: Allow launch site URL to be overridden at runtime
authorKeith Packard <keithp@keithp.com>
Sun, 7 Oct 2018 02:27:43 +0000 (19:27 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 7 Oct 2018 02:48:41 +0000 (19:48 -0700)
Expose a public variable, AltosLaunchSites.launch_sites_url, that will
be used in place of the environment variable or pre-defined value.

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

index b24cccb..2c04c90 100644 (file)
@@ -30,6 +30,8 @@ public class AltosLaunchSites extends Thread {
        LinkedList<AltosLaunchSite>     sites;
        AltosLaunchSiteListener         listener;
 
+       public static String            launch_sites_url;
+
        void notify_complete() {
                listener.notify_launch_sites(sites);
        }
@@ -50,9 +52,13 @@ public class AltosLaunchSites extends Thread {
                try {
                        String  path;
 
-                       path = System.getenv(AltosLib.launch_sites_env);
-                       if (path == null)
-                               path = AltosLib.launch_sites_url;
+                       if (launch_sites_url != null)
+                               path = launch_sites_url;
+                       else {
+                               path = System.getenv(AltosLib.launch_sites_env);
+                               if (path == null)
+                                       path = AltosLib.launch_sites_url;
+                       }
                        url = new URL(path);
                        URLConnection uc = url.openConnection();