Fix double progress
This commit is contained in:
parent
652d9209a8
commit
b6885b5a33
2 changed files with 20 additions and 8 deletions
|
@ -20,4 +20,22 @@ public class RouteCalculationProgress {
|
||||||
|
|
||||||
public boolean isCancelled;
|
public boolean isCancelled;
|
||||||
public boolean requestPrivateAccessRouting;
|
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() {
|
public void run() {
|
||||||
RouteCalculationProgress calculationProgress = params.calculationProgress;
|
RouteCalculationProgress calculationProgress = params.calculationProgress;
|
||||||
if (isRouteBeingCalculated()) {
|
if (isRouteBeingCalculated()) {
|
||||||
float p = Math.max(calculationProgress.distanceFromBegin, calculationProgress.distanceFromEnd);
|
float pr = calculationProgress.getLinearProgress();
|
||||||
float all = calculationProgress.totalEstimatedDistance * 1.25f;
|
progressRoute.updateProgress((int) pr);
|
||||||
if (all > 0) {
|
|
||||||
int t = (int) Math.min(p * p / (all * all) * 100f, 99);
|
|
||||||
progressRoute.updateProgress(t);
|
|
||||||
} else {
|
|
||||||
progressRoute.updateProgress(0);
|
|
||||||
}
|
|
||||||
Thread t = currentRunningJob;
|
Thread t = currentRunningJob;
|
||||||
if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) {
|
if(t instanceof RouteRecalculationThread && ((RouteRecalculationThread) t).params != params) {
|
||||||
// different calculation started
|
// different calculation started
|
||||||
|
|
Loading…
Reference in a new issue