use of net.osmand.plus.GpxSelectionHelper 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 in project Osmand by osmandapp.
the class WptPtMenuController method getTypeStr.
@Override
public String getTypeStr() {
GpxSelectionHelper helper = getMapActivity().getMyApplication().getSelectedGpxHelper();
SelectedGpxFile selectedGpxFile = helper.getSelectedGPXFile(wpt);
StringBuilder sb = new StringBuilder();
sb.append(getMapActivity().getString(R.string.gpx_wpt));
sb.append(", ");
if (selectedGpxFile != null) {
File file = new File(selectedGpxFile.getGpxFile().path);
String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
sb.append(gpxName);
}
return sb.toString();
}
use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.
the class MapMarkersGroupsAdapter method switchGpxVisibility.
private void switchGpxVisibility(@NonNull GPXFile gpxFile, boolean visible) {
GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper();
gpxHelper.selectGpxFile(gpxFile, visible, false, false);
}
use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.
the class OsmandAidlApi method finishGpxImport.
private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) {
int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(app.getRendererRegistry().getCurrentSelectedRenderer(), color);
if (!destinationExists) {
GpxDataItem gpxDataItem = new GpxDataItem(destination, col);
gpxDataItem.setApiImported(true);
app.getGpxDatabase().add(gpxDataItem);
} else {
GpxDataItem item = app.getGpxDatabase().getItem(destination);
if (item != null) {
app.getGpxDatabase().updateColor(item, col);
}
}
final GpxSelectionHelper helper = app.getSelectedGpxHelper();
final SelectedGpxFile selectedGpx = helper.getSelectedFileByName(destination.getName());
if (selectedGpx != null) {
if (show) {
new AsyncTask<File, Void, GPXFile>() {
@Override
protected GPXFile doInBackground(File... files) {
return GPXUtilities.loadGPXFile(app, files[0]);
}
@Override
protected void onPostExecute(GPXFile gpx) {
if (gpx.warning == null) {
selectedGpx.setGpxFile(gpx);
refreshMap();
}
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, destination);
} else {
helper.selectGpxFile(selectedGpx.getGpxFile(), false, false);
refreshMap();
}
} else if (show) {
new AsyncTask<File, Void, GPXFile>() {
@Override
protected GPXFile doInBackground(File... files) {
return GPXUtilities.loadGPXFile(app, files[0]);
}
@Override
protected void onPostExecute(GPXFile gpx) {
if (gpx.warning == null) {
helper.selectGpxFile(gpx, true, false);
refreshMap();
}
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, destination);
}
}
use of net.osmand.plus.GpxSelectionHelper in project Osmand by osmandapp.
the class DashTrackFragment method updateShowOnMap.
private void updateShowOnMap(final OsmandApplication app, final File f, final View pView, final ImageButton showOnMap) {
final GpxSelectionHelper selectedGpxHelper = app.getSelectedGpxHelper();
final SelectedGpxFile selected = selectedGpxHelper.getSelectedFileByPath(f.getAbsolutePath());
if (selected != null) {
showOnMap.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_show_on_map, R.color.color_distance));
showOnMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
selectedGpxHelper.selectGpxFile(selected.getGpxFile(), false, false);
AvailableGPXFragment.GpxInfo info = new AvailableGPXFragment.GpxInfo();
info.subfolder = "";
info.file = f;
AvailableGPXFragment.updateGpxInfoView(pView, info, app, true);
updateShowOnMap(app, f, v, showOnMap);
}
});
} else {
showOnMap.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_show_on_map));
showOnMap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Runnable run = new Runnable() {
@Override
public void run() {
showOnMap(GPXUtilities.loadGPXFile(app, f));
}
};
run.run();
}
});
}
}
Aggregations