use of net.osmand.CallbackWithObject in project Osmand by osmandapp.
the class MeasurementToolFragment method showAddToTrackDialog.
private AlertDialog showAddToTrackDialog(final MapActivity mapActivity) {
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@Override
public boolean processResult(GPXFile[] result) {
GPXFile gpxFile;
if (result != null && result.length > 0) {
gpxFile = result[0];
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path);
boolean showOnMap = selectedGpxFile != null;
saveExistingGpx(gpxFile, showOnMap, ActionType.ADD_SEGMENT, false);
}
return true;
}
};
return GpxUiHelper.selectGPXFile(mapActivity, false, false, callbackWithObject);
}
use of net.osmand.CallbackWithObject in project Osmand by osmandapp.
the class MapContextMenu method addNewWptToGPXFile.
public AlertDialog addNewWptToGPXFile(final String title) {
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@Override
public boolean processResult(GPXFile[] result) {
GPXFile gpxFile;
if (result != null && result.length > 0) {
gpxFile = result[0];
} else {
gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
}
getWptPtPointEditor().add(gpxFile, latLon, title);
return true;
}
};
return GpxUiHelper.selectSingleGPXFile(mapActivity, true, callbackWithObject);
}
use of net.osmand.CallbackWithObject in project Osmand by osmandapp.
the class MapContextMenu method addNewWptToGPXFile.
public AlertDialog addNewWptToGPXFile(final LatLon latLon, final String title, final String categoryName, final int categoryColor, final boolean skipDialog) {
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@Override
public boolean processResult(GPXFile[] result) {
GPXFile gpxFile;
if (result != null && result.length > 0) {
gpxFile = result[0];
} else {
gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
}
getWptPtPointEditor().add(gpxFile, latLon, title, categoryName, categoryColor, skipDialog);
return true;
}
};
return GpxUiHelper.selectSingleGPXFile(mapActivity, true, callbackWithObject);
}
use of net.osmand.CallbackWithObject in project Osmand by osmandapp.
the class MapActivityLayers method showGPXFileLayer.
public AlertDialog showGPXFileLayer(List<String> files, final OsmandMapTileView mapView) {
final OsmandSettings settings = getApplication().getSettings();
CallbackWithObject<GPXFile[]> callbackWithObject = new CallbackWithObject<GPXFile[]>() {
@Override
public boolean processResult(GPXFile[] result) {
WptPt locToShow = null;
for (GPXFile g : result) {
if (g.showCurrentTrack) {
if (!settings.SAVE_TRACK_TO_GPX.get() && !settings.SAVE_GLOBAL_TRACK_TO_GPX.get()) {
Toast.makeText(activity, R.string.gpx_monitoring_disabled_warn, Toast.LENGTH_LONG).show();
}
break;
} else {
locToShow = g.findPointToShow();
}
}
getApplication().getSelectedGpxHelper().setGpxFileToDisplay(result);
if (locToShow != null) {
mapView.getAnimatedDraggingThread().startMoving(locToShow.lat, locToShow.lon, mapView.getZoom(), true);
}
mapView.refreshMap();
activity.getDashboard().refreshContent(true);
return true;
}
};
return GpxUiHelper.selectGPXFiles(files, activity, callbackWithObject);
}
use of net.osmand.CallbackWithObject in project Osmand by osmandapp.
the class OsmAndLocationSimulation method startStopRouteAnimation.
// public void startStopRouteAnimationRoute(final MapActivity ma) {
// if (!isRouteAnimating()) {
// List<Location> currentRoute = app.getRoutingHelper().getCurrentRoute();
// if (currentRoute.isEmpty()) {
// Toast.makeText(app, R.string.animate_routing_route_not_calculated, Toast.LENGTH_LONG).show();
// } else {
// startAnimationThread(app.getRoutingHelper(), ma, new ArrayList<Location>(currentRoute), false, 1);
// }
// } else {
// stop();
// }
// }
public void startStopRouteAnimation(final Activity ma, final Runnable runnable) {
if (!isRouteAnimating()) {
AlertDialog.Builder builder = new AlertDialog.Builder(ma);
builder.setTitle(R.string.animate_route);
final View view = ma.getLayoutInflater().inflate(R.layout.animate_route, null);
final View gpxView = ((LinearLayout) view.findViewById(R.id.layout_animate_gpx));
final RadioButton radioGPX = (RadioButton) view.findViewById(R.id.radio_gpx);
radioGPX.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
gpxView.setVisibility(isChecked ? View.VISIBLE : View.GONE);
}
});
// $NON-NLS-1$
((TextView) view.findViewById(R.id.MinSpeedup)).setText("1");
// $NON-NLS-1$
((TextView) view.findViewById(R.id.MaxSpeedup)).setText("4");
final SeekBar speedup = (SeekBar) view.findViewById(R.id.Speedup);
speedup.setMax(3);
builder.setView(view);
builder.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
boolean gpxNavigation = radioGPX.isChecked();
if (gpxNavigation) {
GpxUiHelper.selectGPXFile(ma, false, false, new CallbackWithObject<GPXUtilities.GPXFile[]>() {
@Override
public boolean processResult(GPXUtilities.GPXFile[] result) {
GPXRouteParamsBuilder builder = new GPXRouteParamsBuilder(result[0], app.getSettings());
startAnimationThread(app, builder.getPoints(), true, speedup.getProgress() + 1);
if (runnable != null) {
runnable.run();
}
return true;
}
});
} else {
List<Location> currentRoute = app.getRoutingHelper().getCurrentCalculatedRoute();
if (currentRoute.isEmpty()) {
Toast.makeText(app, R.string.animate_routing_route_not_calculated, Toast.LENGTH_LONG).show();
} else {
startAnimationThread(app, new ArrayList<Location>(currentRoute), false, 1);
if (runnable != null) {
runnable.run();
}
}
}
}
});
builder.setNegativeButton(R.string.shared_string_cancel, null);
builder.show();
} else {
stop();
}
}
Aggregations