diff options
author | Keith Packard <keithp@keithp.com> | 2016-05-11 12:48:10 -0700 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-05-11 23:22:15 -0700 |
commit | 2ec7e14f0104e3a227ff566fa2fc1f6286ddd9d0 (patch) | |
tree | 17f703dc3e92a6d0dc86976b02934a13d9bbaa1a /altosdroid | |
parent | ab905d2f7d8929080042cfd16cc418ea5792c3cb (diff) |
altoslib: Get rid of AltosMap from AltosMapLoader
Cleans up the loader API and eliminates a AltosMapTile for every chunk
of map data.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'altosdroid')
-rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java | 12 | ||||
-rw-r--r-- | altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java | 75 |
2 files changed, 14 insertions, 73 deletions
diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java b/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java index ab142b17..e7edf3c0 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/AltosMapOffline.java @@ -85,6 +85,8 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal AltosMap map; AltosDroid altos_droid; + static int scale = 2; + AltosLatLon here; AltosLatLon there; AltosLatLon pad; @@ -181,14 +183,14 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal } } - public MapTile(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 MapTile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size, int scale) { + super(cache, upper_left, center, zoom, maptype, px_size, scale); } } - public AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size) { - return new MapTile(cache, upper_left, center, zoom, maptype, px_size); + public AltosMapTile new_tile(AltosMapCache cache, AltosLatLon upper_left, AltosLatLon center, int zoom, int maptype, int px_size, int scale) { + return new MapTile(cache, upper_left, center, zoom, maptype, px_size, scale); } public AltosMapPath new_path() { @@ -492,7 +494,7 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal public void onCreateView(AltosDroid altos_droid) { this.altos_droid = altos_droid; - map = new AltosMap(this); + map = new AltosMap(this, scale); AltosPreferences.register_map_type_listener(this); map.set_maptype(AltosPreferences.map_type()); diff --git a/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java b/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java index 11d71280..9dfc727e 100644 --- a/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java +++ b/altosdroid/src/org/altusmetrum/AltosDroid/PreloadMapActivity.java @@ -49,7 +49,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<AltosLaunchSite> known_sites_adapter; @@ -110,7 +110,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<AltosLaunchSite> sites) { this.runOnUiThread(new Runnable() { public void run() { @@ -120,70 +125,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; @@ -281,7 +222,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()); } @@ -412,8 +353,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); |