use of net.osmand.plus.routing.RoutingHelper.RouteCalculationProgressCallback in project Osmand by osmandapp.
the class MapActivity method createProgressBarForRouting.
private void createProgressBarForRouting() {
final ProgressBar pb = (ProgressBar) findViewById(R.id.map_horizontal_progress);
final View pbExtView = findViewById(R.id.progress_layout_external);
final ProgressBar pbExt = (ProgressBar) findViewById(R.id.map_horizontal_progress_external);
app.getRoutingHelper().setProgressBar(new RouteCalculationProgressCallback() {
@Override
public void updateProgress(int progress) {
if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) {
if (pbExtView.getVisibility() == View.VISIBLE) {
pbExtView.setVisibility(View.GONE);
}
if (pb.getVisibility() == View.GONE) {
pb.setVisibility(View.VISIBLE);
}
pb.setProgress(progress);
pb.invalidate();
pb.requestLayout();
} else {
if (pb.getVisibility() == View.VISIBLE) {
pb.setVisibility(View.GONE);
}
if (pbExtView.getVisibility() == View.GONE) {
pbExtView.setVisibility(View.VISIBLE);
}
pbExt.setProgress(progress);
pbExt.invalidate();
pbExt.requestLayout();
}
}
@Override
public void requestPrivateAccessRouting() {
if (!settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.getModeValue(getRoutingHelper().getAppMode())) {
final OsmandSettings.CommonPreference<Boolean> allowPrivate = settings.getCustomRoutingBooleanProperty(GeneralRouter.ALLOW_PRIVATE, false);
final List<ApplicationMode> modes = ApplicationMode.values(settings);
for (ApplicationMode mode : modes) {
if (!allowPrivate.getModeValue(mode)) {
settings.FORCE_PRIVATE_ACCESS_ROUTING_ASKED.setModeValue(mode, true);
}
}
if (!allowPrivate.getModeValue(getRoutingHelper().getAppMode())) {
AlertDialog.Builder dlg = new AlertDialog.Builder(MapActivity.this);
dlg.setMessage(R.string.private_access_routing_req);
dlg.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
for (ApplicationMode mode : modes) {
if (!allowPrivate.getModeValue(mode)) {
allowPrivate.setModeValue(mode, true);
}
}
getRoutingHelper().recalculateRouteDueToSettingsChange();
}
});
dlg.setNegativeButton(R.string.shared_string_no, null);
dlg.show();
}
}
}
@Override
public void finish() {
pbExtView.setVisibility(View.GONE);
pb.setVisibility(View.GONE);
}
});
}
Aggregations