use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class MapActivityActions method enterRoutePlanningMode.
public void enterRoutePlanningMode(final LatLon from, final PointDescription fromName) {
final boolean useIntermediatePointsByDefault = true;
List<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
final List<GPXFile> gpxFiles = new ArrayList<>();
for (SelectedGpxFile gs : selectedGPXFiles) {
if (!gs.isShowCurrentTrack() && !gs.notShowNavigationDialog) {
if (gs.getGpxFile().hasRtePt() || gs.getGpxFile().hasTrkPt()) {
gpxFiles.add(gs.getGpxFile());
}
}
}
if (gpxFiles.size() > 0) {
AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
if (gpxFiles.size() == 1) {
bld.setMessage(R.string.use_displayed_track_for_navigation);
bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName, useIntermediatePointsByDefault, true);
}
});
} else {
bld.setTitle(R.string.navigation_over_track);
ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity, R.layout.drawer_list_item, gpxFiles) {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null) {
convertView = mapActivity.getLayoutInflater().inflate(R.layout.drawer_list_item, null);
}
String path = getItem(position).path;
String name = path.substring(path.lastIndexOf("/") + 1, path.length());
((TextView) convertView.findViewById(R.id.title)).setText(name);
convertView.findViewById(R.id.icon).setVisibility(View.GONE);
convertView.findViewById(R.id.toggle_item).setVisibility(View.GONE);
return convertView;
}
};
bld.setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName, useIntermediatePointsByDefault, true);
}
});
}
bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
}
});
bld.show();
} else {
enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
}
}
use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class TrackActivity method getGpxFile.
public List<GpxDisplayGroup> getGpxFile(boolean useDisplayGroups) {
if (gpxFile == null) {
return new ArrayList<>();
}
if (gpxFile.modifiedTime != modifiedTime) {
modifiedTime = gpxFile.modifiedTime;
GpxSelectionHelper selectedGpxHelper = ((OsmandApplication) getApplication()).getSelectedGpxHelper();
displayGroups = selectedGpxHelper.collectDisplayGroups(gpxFile);
originalGroups.clear();
for (GpxDisplayGroup g : displayGroups) {
originalGroups.add(g.cloneInstance());
}
if (file != null) {
SelectedGpxFile sf = selectedGpxHelper.getSelectedFileByPath(gpxFile.path);
if (sf != null && file != null && sf.getDisplayGroups() != null) {
displayGroups = sf.getDisplayGroups();
}
}
}
if (useDisplayGroups) {
return displayGroups;
} else {
return originalGroups;
}
}
use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class GPXLayer method drawSelectedFilesSplits.
private void drawSelectedFilesSplits(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
if (tileBox.getZoom() >= startZoom) {
// request to load
for (SelectedGpxFile g : selectedGPXFiles) {
List<GpxDisplayGroup> groups = g.getDisplayGroups();
if (groups != null && !groups.isEmpty()) {
GpxDataItem gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(g.getGpxFile().path));
int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
if (color == 0) {
color = g.getModifiableGpxFile().getColor(0);
}
if (color == 0) {
color = cachedColor;
}
paintInnerRect.setColor(color);
paintInnerRect.setAlpha(179);
List<GpxDisplayItem> items = groups.get(0).getModifiableList();
drawSplitItems(canvas, tileBox, items, settings);
}
}
}
}
use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class GPXLayer method onPrepareBufferImage.
@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
if (points != null) {
updatePaints(0, false, false, settings, tileBox);
for (TrkSegment ts : points) ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
} else {
List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
cache.clear();
currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
if (!selectedGPXFiles.isEmpty()) {
drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
if (trackChartPoints != null) {
drawXAxisPoints(canvas, tileBox);
}
drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
}
if (textLayer != null && textLayer.isVisible()) {
textLayer.putData(this, cache);
}
}
}
use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class MapContextMenu method addWptPt.
public void addWptPt() {
String title = getTitleStr();
if (pointDescription.isWpt() || !hasValidTitle()) {
title = "";
}
final List<SelectedGpxFile> list = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
if ((list.isEmpty() || (list.size() == 1 && list.get(0).getGpxFile().showCurrentTrack)) && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
GPXFile gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
getWptPtPointEditor().add(gpxFile, latLon, title);
} else {
addNewWptToGPXFile(title);
}
}
Aggregations