synchronized (notificationMutex) {
for (int i = 0; i < startPositions.length; i++) {
// skip the very last position without successor
if (i == positions.size() - 1 || i == startPositions.length - 1)
continue;
addToQueue.put(random.nextInt(), new PositionPair(positions.get(startPositions[i]), positions.get(startPositions[i] + 1)));
}
}
synchronized (insertWaypointsQueue) {
insertWaypointsQueue.putAll(addToQueue);
}
insertWaypointsExecutor.execute(new Runnable() {
public void run() {
for (Integer key : addToQueue.keySet()) {
PositionPair pair = addToQueue.get(key);
NavigationPosition origin = pair.getFirst();
NavigationPosition destination = pair.getSecond();
StringBuilder buffer = new StringBuilder();
buffer.append(mode).append("({");
buffer.append("origin: new google.maps.LatLng(").append(origin.getLatitude()).append(",").append(origin.getLongitude()).append("), ");
buffer.append("destination: new google.maps.LatLng(").append(destination.getLatitude()).append(",").append(destination.getLongitude()).append("), ");
buffer.append("travelMode: google.maps.DirectionsTravelMode.").append(mapViewCallback.getTravelMode().getName().toUpperCase()).append(", ");