Create initial progress

This commit is contained in:
Victor Shcherb 2018-05-30 11:45:19 +02:00
parent 35c53ed5e3
commit 50647d29f7

View file

@ -21,21 +21,26 @@ public class RouteCalculationProgress {
public boolean isCancelled; public boolean isCancelled;
public boolean requestPrivateAccessRouting; public boolean requestPrivateAccessRouting;
private static final float FIRST_ITERATION = 0.75f; private static final float INITIAL_PROGRSS = 0.05f;
private static final float FIRST_ITERATION = 0.72f;
public float getLinearProgress() { public float getLinearProgress() {
float p = Math.max(distanceFromBegin, distanceFromEnd); float p = Math.max(distanceFromBegin, distanceFromEnd);
float all = totalEstimatedDistance * 1.25f; float all = totalEstimatedDistance * 1.25f;
float pr = 0; float pr = 0;
if (all > 0) { if (all > 0) {
pr = Math.min(p * p / (all * all) * 100f, 99); pr = p * p / (all * all);
} }
float progress = INITIAL_PROGRSS;
if (totalIterations > 1) { if (totalIterations > 1) {
if (iteration <= 0) { if (iteration <= 0) {
return pr * FIRST_ITERATION; progress = pr * FIRST_ITERATION + INITIAL_PROGRSS;
} else { } else {
return Math.min(FIRST_ITERATION * 100 + pr * (1 - FIRST_ITERATION), 99); progress = (INITIAL_PROGRSS + FIRST_ITERATION) + pr * (1 - FIRST_ITERATION - INITIAL_PROGRSS);
} }
} } else {
return pr; progress = INITIAL_PROGRSS + pr * (1 - INITIAL_PROGRSS);
}
return Math.min(progress * 100f, 99);
} }
} }