Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2014-12-09 22:26:06 +01:00
commit 163cf694a3
2 changed files with 23 additions and 18 deletions

View file

@ -59,27 +59,31 @@ public class CurrentPositionHelper {
} }
private void scheduleRouteSegmentFind(final Location loc){ private void scheduleRouteSegmentFind(final Location loc) {
if(calculatingThread == Thread.currentThread()) { if (calculatingThread == Thread.currentThread()) {
lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude()); lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude());
} else if(calculatingThread == null && loc != null) { } else if (loc != null) {
Runnable run = new Runnable() { if (calculatingThread == null) {
@Override Runnable run = new Runnable() {
public void run() { @Override
try { public void run() {
lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude()); try {
if (lastAskedLocation != loc) { lastFound = runUpdateInThreadCatch(loc.getLatitude(), loc.getLongitude());
// refresh and run new task if needed if (lastAskedLocation != loc) {
getLastKnownRouteSegment(lastAskedLocation); // refresh and run new task if needed
getLastKnownRouteSegment(lastAskedLocation);
}
} finally {
calculatingThread = null;
} }
} finally {
calculatingThread = null;
} }
} };
}; calculatingThread = app.getRoutingHelper().startTaskInRouteThreadIfPossible(run);
calculatingThread = app.getRoutingHelper().startTaskInRouteThreadIfPossible(run); } else if (!calculatingThread.isAlive()) {
calculatingThread = null;
}
} }
} }
protected RouteDataObject runUpdateInThreadCatch(double latitude, double longitude) { protected RouteDataObject runUpdateInThreadCatch(double latitude, double longitude) {

View file

@ -823,8 +823,9 @@ public class RoutingHelper {
}, "Calculating position"); //$NON-NLS-1$ }, "Calculating position"); //$NON-NLS-1$
currentRunningJob.start(); currentRunningJob.start();
} }
return currentRunningJob;
} }
return currentRunningJob; return null;
} }