This commit is contained in:
Alexey Kulish 2017-10-15 14:39:24 +03:00
parent 309e6f4bfd
commit 33b579972b
3 changed files with 21 additions and 9 deletions

View file

@ -758,7 +758,7 @@ public class OsmandApplication extends MultiDexApplication {
return lang; return lang;
} }
public RoutingConfiguration.Builder getDefaultRoutingConfig() { public synchronized RoutingConfiguration.Builder getDefaultRoutingConfig() {
if(defaultRoutingConfig == null) { if(defaultRoutingConfig == null) {
defaultRoutingConfig = appInitializer.getLazyDefaultRoutingConfig(); defaultRoutingConfig = appInitializer.getLazyDefaultRoutingConfig();
} }

View file

@ -403,14 +403,24 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override @Override
public void updateProgress(int progress) { public void updateProgress(int progress) {
if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) { if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) {
pbExtView.setVisibility(View.GONE); if (pbExtView.getVisibility() == View.VISIBLE) {
pb.setVisibility(View.VISIBLE); pbExtView.setVisibility(View.GONE);
}
if (pb.getVisibility() == View.GONE) {
pb.setVisibility(View.VISIBLE);
}
pb.setProgress(progress); pb.setProgress(progress);
pb.invalidate();
pb.requestLayout(); pb.requestLayout();
} else { } else {
pb.setVisibility(View.GONE); if (pb.getVisibility() == View.VISIBLE) {
pbExtView.setVisibility(View.VISIBLE); pb.setVisibility(View.GONE);
}
if (pbExtView.getVisibility() == View.GONE) {
pbExtView.setVisibility(View.VISIBLE);
}
pbExt.setProgress(progress); pbExt.setProgress(progress);
pbExt.invalidate();
pbExt.requestLayout(); pbExt.requestLayout();
} }
} }

View file

@ -952,14 +952,14 @@ public class RoutingHelper {
} }
public void startRouteCalculationThread(RouteCalculationParams params, boolean paramsChanged, boolean updateProgress) { public void startRouteCalculationThread(RouteCalculationParams params, boolean paramsChanged, boolean updateProgress) {
if (updateProgress) {
updateProgress(params);
}
synchronized (this) { synchronized (this) {
final Thread prevRunningJob = currentRunningJob; final Thread prevRunningJob = currentRunningJob;
RouteRecalculationThread newThread = new RouteRecalculationThread( RouteRecalculationThread newThread = new RouteRecalculationThread(
"Calculating route", params, paramsChanged); //$NON-NLS-1$ "Calculating route", params, paramsChanged); //$NON-NLS-1$
currentRunningJob = newThread; currentRunningJob = newThread;
if (updateProgress) {
updateProgress(params);
}
if (prevRunningJob != null) { if (prevRunningJob != null) {
newThread.setWaitPrevJob(prevRunningJob); newThread.setWaitPrevJob(prevRunningJob);
} }
@ -974,7 +974,7 @@ public class RoutingHelper {
} else { } else {
progressRoute = this.progressRoute; progressRoute = this.progressRoute;
} }
if(progressRoute != null ) { if (progressRoute != null ) {
app.runInUIThread(new Runnable() { app.runInUIThread(new Runnable() {
@Override @Override
@ -986,6 +986,8 @@ public class RoutingHelper {
if (all > 0) { if (all > 0) {
int t = (int) Math.min(p * p / (all * all) * 100f, 99); int t = (int) Math.min(p * p / (all * all) * 100f, 99);
progressRoute.updateProgress(t); 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) {