Fix double progress
This commit is contained in:
parent
eabb2770f8
commit
91a2d484ce
2 changed files with 20 additions and 8 deletions
|
@ -20,4 +20,22 @@ public class RouteCalculationProgress {
|
|||
|
||||
public boolean isCancelled;
|
||||
public boolean requestPrivateAccessRouting;
|
||||
|
||||
private static final float FIRST_ITERATION = 0.75f;
|
||||
public float getLinearProgress() {
|
||||
float p = Math.max(distanceFromBegin, distanceFromEnd);
|
||||
float all = totalEstimatedDistance * 1.25f;
|
||||
float pr = 0;
|
||||
if (all > 0) {
|
||||
pr = Math.min(p * p / (all * all) * 100f, 99);
|
||||
}
|
||||
if(totalIterations > 1) {
|
||||
if(iteration <= 0) {
|
||||
return pr * FIRST_ITERATION;
|
||||
} else {
|
||||
return Math.min(FIRST_ITERATION * 100 + pr * (1 - FIRST_ITERATION), 99);
|
||||
}
|
||||
}
|
||||
return pr;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1006,14 +1006,8 @@ public class RoutingHelper {
|
|||
public void run() {
|
||||
RouteCalculationProgress calculationProgress = params.calculationProgress;
|
||||
if (isRouteBeingCalculated()) {
|
||||
float p = Math.max(calculationProgress.distanceFromBegin, calculationProgress.distanceFromEnd);
|
||||
float all = calculationProgress.totalEstimatedDistance * 1.25f;
|
||||
if (all > 0) {
|
||||
int t = (int) Math.min(p * p / (all * all) * 100f, 99);
|
||||
progressRoute.updateProgress(t);
|
||||
} else {
|
||||
progressRoute.updateProgress(0);
|
||||
}
|
||||
float pr = calculationProgress.getLinearProgress();
|
||||
progressRoute.updateProgress((int) pr);
|
||||
Thread t = currentRunningJob;
|
||||
if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) {
|
||||
// different calculation started
|
||||
|
|
Loading…
Reference in a new issue