Bump Java library versions
[fw/altos] / altosdroid / src / org / altusmetrum / AltosDroid / AltosMapOffline.java
index 12dd2f252c74e9130f6224006511fe762c52e1cd..eb0599010729058ae7ac22c97ea55f57ec3d7766 100644 (file)
@@ -20,7 +20,7 @@ package org.altusmetrum.AltosDroid;
 import java.util.*;
 import java.io.*;
 
-import org.altusmetrum.altoslib_7.*;
+import org.altusmetrum.altoslib_8.*;
 
 import android.app.Activity;
 import android.graphics.*;
@@ -86,6 +86,7 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
        AltosDroid              altos_droid;
 
        AltosLatLon     here;
+       AltosLatLon     there;
        AltosLatLon     pad;
 
        Canvas  canvas;
@@ -252,6 +253,8 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
        public void select_object(AltosLatLon latlon) {
                if (map.transform == null)
                        return;
+               ArrayList<Integer>      near = new ArrayList<Integer>();
+
                for (Rocket rocket : sorted_rockets()) {
                        if (rocket.position == null) {
                                debug("rocket %d has no position\n", rocket.serial);
@@ -261,10 +264,11 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
                        debug("check select %d distance %g width %d\n", rocket.serial, distance, rocket_bitmap.getWidth());
                        if (distance < rocket_bitmap.getWidth() * 2.0) {
                                debug("selecting %d\n", rocket.serial);
-                               altos_droid.select_tracker(rocket.serial);
-                               break;
+                               near.add(rocket.serial);
                        }
                }
+               if (near.size() != 0)
+                       altos_droid.touch_trackers(near.toArray(new Integer[0]));
        }
 
        class Line {
@@ -334,7 +338,7 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
        }
 
        private void draw_positions() {
-               line.set_a(map.last_position);
+               line.set_a(there);
                line.set_b(here);
                line.paint();
                draw_bitmap(pad, pad_bitmap, pad_off_x, pad_off_y);
@@ -358,7 +362,6 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
 
        @Override
        protected void onDraw(Canvas view_canvas) {
-               debug("onDraw");
                if (map == null) {
                        debug("MapView draw without map\n");
                        return;
@@ -423,7 +426,7 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
        double  mapAccuracy;
 
        public void center(double lat, double lon, double accuracy) {
-               if (mapAccuracy < 0 || accuracy < mapAccuracy/10) {
+               if (mapAccuracy <= 0 || accuracy < mapAccuracy/10 || (map != null && !map.has_centre())) {
                        if (map != null)
                                map.maybe_centre(lat, lon);
                        mapAccuracy = accuracy;
@@ -465,8 +468,12 @@ public class AltosMapOffline extends View implements ScaleGestureDetector.OnScal
                                        rocket = new Rocket(serial, this);
                                        rockets.put(serial, rocket);
                                }
-                               if (t_state.gps != null)
-                                       rocket.set_position(new AltosLatLon(t_state.gps.lat, t_state.gps.lon), t_state.received_time);
+                               if (t_state.gps != null) {
+                                       AltosLatLon     latlon = new AltosLatLon(t_state.gps.lat, t_state.gps.lon);
+                                       rocket.set_position(latlon, t_state.received_time);
+                                       if (state.serial == serial)
+                                               there = latlon;
+                               }
                                if (state != null)
                                        rocket.set_active(state.serial == serial);
                        }