Location for OsMo now always has time.

This commit is contained in:
GaidamakUA 2016-03-16 11:55:05 +02:00 committed by Victor Shcherb
parent ce0ac13cc3
commit a31fa8e7a7

View file

@ -29,7 +29,7 @@ public class OsMoTracker implements OsMoReactor {
integerFormat.setDecimalFormatSymbols(symbols);
}
private ConcurrentLinkedQueue<Location> bufferOfLocations = new ConcurrentLinkedQueue<Location>();
private ConcurrentLinkedQueue<Location> bufferOfLocations = new ConcurrentLinkedQueue<>();
private OsMoService service;
private int locationsSent = 0;
private OsmoTrackerListener trackerListener = null;
@ -37,16 +37,14 @@ public class OsMoTracker implements OsMoReactor {
private Location lastBufferLocation;
private OsmandPreference<Integer> pref;
private String sessionURL;
private Map<String, OsMoDevice> trackingDevices = new java.util.concurrent.ConcurrentHashMap<String, OsMoGroupsStorage.OsMoDevice>();
private Map<String, OsMoDevice> trackingDevices = new java.util.concurrent.ConcurrentHashMap<>();
private OsmandPreference<Boolean> stateSendLocation;
protected static final Log LOG = PlatformUtil.getLog(OsMoTracker.class);
public interface OsmoTrackerListener {
public void locationChange(String trackerId, Location location);
void locationChange(String trackerId, Location location);
}
public OsMoTracker(OsMoService service, OsmandPreference<Integer> interval,
OsmandPreference<Boolean> stateSendLocation) {
this.service = service;
@ -131,7 +129,7 @@ public class OsMoTracker implements OsMoReactor {
cmd.append("C");
integerFormat.format(loc.getBearing(), cmd, new FieldPosition(cmd.length()));
}
if ((System.currentTimeMillis() - loc.getTime()) > 30000 && loc.getTime() != 0) {
if (loc.getTime() != 0) {
cmd.append("T");
integerFormat.format(loc.getTime(), cmd, new FieldPosition(cmd.length()));
}
@ -180,13 +178,14 @@ public class OsMoTracker implements OsMoReactor {
@Override
public boolean acceptCommand(String command, String tid, String data, JSONObject obj, OsMoThread thread) {
if (command.equals("LISTEN")) {
switch (command) {
case "LISTEN":
return true;
} else if (command.equals("UNLISTEN")) {
case "UNLISTEN":
return true;
} else if (command.equals("TRACKER_SESSION_CLOSE")) {
case "TRACKER_SESSION_CLOSE":
return true;
} else if (command.equals("TRACKER_SESSION_OPEN")) {
case "TRACKER_SESSION_OPEN":
try {
sessionURL = obj.getString("url");
} catch (JSONException e) {
@ -194,7 +193,7 @@ public class OsMoTracker implements OsMoReactor {
e.printStackTrace();
}
return true;
} else if (command.equals("LT")) {
case "LT":
double lat = 0;
double lon = 0;
double speed = 0;