Show indeterminate progress for not osmand routing
This commit is contained in:
parent
b3fe910193
commit
25bdbfc502
3 changed files with 20 additions and 7 deletions
|
@ -588,8 +588,9 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
? mapLayers.getRouteLayer().getRouteLineColor(nightMode)
|
||||
: ContextCompat.getColor(this, R.color.wikivoyage_active_light);
|
||||
|
||||
RoutingHelper routingHelper = getRoutingHelper();
|
||||
pb.setProgressDrawable(AndroidUtils.createProgressDrawable(bgColor, progressColor));
|
||||
pb.setIndeterminate(getRoutingHelper().isPublicTransportMode());
|
||||
pb.setIndeterminate(routingHelper.isPublicTransportMode() || !routingHelper.isOsmandRouting());
|
||||
pb.getIndeterminateDrawable().setColorFilter(progressColor, android.graphics.PorterDuff.Mode.SRC_IN);
|
||||
}
|
||||
|
||||
|
|
|
@ -149,11 +149,14 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
|||
View mainView = getMainView();
|
||||
if (mainView != null) {
|
||||
View progressBar = mainView.findViewById(R.id.progress_bar);
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
boolean progressVisible = progressBar != null && progressBar.getVisibility() == View.VISIBLE;
|
||||
boolean routeCalculating = app.getRoutingHelper().isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated();
|
||||
boolean routeCalculating = routingHelper.isRouteBeingCalculated() || app.getTransportRoutingHelper().isRouteBeingCalculated();
|
||||
if (progressVisible && !routeCalculating) {
|
||||
hideRouteCalculationProgressBar();
|
||||
openMenuHalfScreen();
|
||||
} else if (!progressVisible && routeCalculating && !routingHelper.isOsmandRouting()) {
|
||||
updateRouteCalculationProgress(0);
|
||||
}
|
||||
}
|
||||
menu.addTargetPointListener();
|
||||
|
@ -359,6 +362,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
|||
OsmandApplication app = getMyApplication();
|
||||
return app != null && app.getRoutingHelper().isPublicTransportMode();
|
||||
}
|
||||
|
||||
private boolean isOsmandRouting() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
return app != null && app.getRoutingHelper().isOsmandRouting();
|
||||
}
|
||||
|
||||
public void updateRouteCalculationProgress(int progress) {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
|
@ -367,11 +375,11 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
|||
if (mapActivity == null || mainView == null || view == null) {
|
||||
return;
|
||||
}
|
||||
boolean publicTransportMode = isPublicTransportMode();
|
||||
boolean indeterminate = isPublicTransportMode() || !isOsmandRouting();
|
||||
ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar);
|
||||
if (progressBar != null) {
|
||||
if (progress == 0) {
|
||||
progressBar.setIndeterminate(publicTransportMode);
|
||||
progressBar.setIndeterminate(indeterminate);
|
||||
}
|
||||
if (progressBar.getVisibility() != View.VISIBLE) {
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
|
@ -383,10 +391,10 @@ public class MapRouteInfoMenuFragment extends ContextMenuFragment {
|
|||
if (progressBarButton.getVisibility() != View.VISIBLE) {
|
||||
progressBarButton.setVisibility(View.VISIBLE);
|
||||
}
|
||||
progressBarButton.setProgress(publicTransportMode ? 0 : progress);
|
||||
progressBarButton.setProgress(indeterminate ? 0 : progress);
|
||||
}
|
||||
TextViewExProgress textViewExProgress = (TextViewExProgress) view.findViewById(R.id.start_button_descr);
|
||||
textViewExProgress.percent = publicTransportMode ? 0 : progress / 100f;
|
||||
textViewExProgress.percent = indeterminate ? 0 : progress / 100f;
|
||||
textViewExProgress.invalidate();
|
||||
}
|
||||
|
||||
|
|
|
@ -1073,8 +1073,8 @@ public class RoutingHelper {
|
|||
RouteRecalculationThread newThread = new RouteRecalculationThread(
|
||||
"Calculating route", params, paramsChanged); //$NON-NLS-1$
|
||||
currentRunningJob = newThread;
|
||||
startProgress(params);
|
||||
if (updateProgress) {
|
||||
startProgress(params);
|
||||
updateProgress(params);
|
||||
}
|
||||
if (prevRunningJob != null) {
|
||||
|
@ -1165,6 +1165,10 @@ public class RoutingHelper {
|
|||
return mode.isDerivedRoutingFrom(ApplicationMode.PUBLIC_TRANSPORT);
|
||||
}
|
||||
|
||||
public boolean isOsmandRouting() {
|
||||
return mode.getRouteService() == RouteService.OSMAND;
|
||||
}
|
||||
|
||||
public boolean isRouteBeingCalculated() {
|
||||
return currentRunningJob instanceof RouteRecalculationThread || waitingNextJob;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue