X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=altosdroid%2Fsrc%2Forg%2Faltusmetrum%2FAltosDroid%2FPreloadMapActivity.java;h=9c43870f76c9838e55133da661ee0f3ffb896509;hb=a61217f0a6d0ef48b6471f632c4600255867e831;hp=ab5e433d46d2f0cd4dd650461654b51b2c7ffcdb;hpb=c5f49d0ac254047f13c6c1ecfb5520eff72109ac;p=fw%2Faltos diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java b/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java index ab5e433d..9c43870f 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java @@ -3,7 +3,8 @@ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of @@ -41,7 +42,7 @@ import android.location.LocationManager; import android.location.LocationListener; import android.location.Criteria; -import org.altusmetrum.altoslib_10.*; +import org.altusmetrum.altoslib_12.*; /** * This Activity appears as a dialog. It lists any paired devices and @@ -49,7 +50,7 @@ import org.altusmetrum.altoslib_10.*; * by the user, the MAC address of the device is sent back to the parent * Activity in the result Intent. */ -public class PreloadMapActivity extends Activity implements AltosLaunchSiteListener, AltosMapInterface, AltosMapLoaderListener, LocationListener { +public class PreloadMapActivity extends Activity implements AltosLaunchSiteListener, AltosMapLoaderListener, LocationListener { private ArrayAdapter known_sites_adapter; @@ -75,6 +76,8 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe /* AltosMapLoaderListener interfaces */ public void loader_start(final int max) { + loader_notify_time = System.currentTimeMillis(); + this.runOnUiThread(new Runnable() { public void run() { progress.setMax(max); @@ -84,6 +87,13 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe } public void loader_notify(final int cur, final int max, final String name) { + long now = System.currentTimeMillis(); + + if (now - loader_notify_time < 100) + return; + + loader_notify_time = now; + this.runOnUiThread(new Runnable() { public void run() { progress.setProgress(cur); @@ -101,7 +111,12 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe }); } + public void debug(String format, Object ... arguments) { + AltosDebug.debug(format, arguments); + } + /* AltosLaunchSiteListener interface */ + public void notify_launch_sites(final List sites) { this.runOnUiThread(new Runnable() { public void run() { @@ -111,70 +126,6 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe }); } - AltosMap map; - - class PreloadMapImage implements AltosImage { - public void flush() { - } - - public PreloadMapImage(File file) { - } - } - - public AltosMapPath new_path() { - return null; - } - - public AltosMapLine new_line() { - return null; - } - - public AltosImage load_image(File file) throws Exception { - return new PreloadMapImage(file); - } - - public AltosMapMark new_mark(double lat, double lon, int state) { - return null; - } - - class PreloadMapTile extends AltosMapTile { - public void paint(AltosMapTransform t) { - } - - public PreloadMapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - super(cache, upper_left, center, zoom, maptype, px_size, 2); - } - - } - - public AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - return new PreloadMapTile(cache, upper_left, center, zoom, maptype, px_size); - } - - public int width() { - return AltosMap.px_size; - } - - public int height() { - return AltosMap.px_size; - } - - public void repaint() { - } - - public void repaint(AltosRectangle damage) { - } - - public void set_zoom_label(String label) { - } - - public void select_object(AltosLatLon latlon) { - } - - public void debug(String format, Object ... arguments) { - AltosDebug.debug(format, arguments); - } - /* LocationProvider interface */ AltosLaunchSite current_location_site; @@ -272,7 +223,7 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe AltosDebug.debug("PreloadMap load %f %f %d %d %f %d\n", lat, lon, min, max, r, t); - loader = new AltosMapLoader(map, this, lat, lon, min, max, r, t); + loader = new AltosMapLoader(this, lat, lon, min, max, r, t, AltosMapOffline.scale); } catch (ParseException e) { AltosDebug.debug("PreloadMap load raised exception %s", e.toString()); } @@ -403,8 +354,6 @@ public class PreloadMapActivity extends Activity implements AltosLaunchSiteListe known_sites_spinner.setAdapter(known_sites_adapter); known_sites_spinner.setOnItemSelectedListener(new SiteListListener()); - map = new AltosMap(this); - // Listen for GPS and Network position updates LocationManager locationManager = (LocationManager) this.getSystemService(Context.LOCATION_SERVICE);