use of net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class MapLayerMenuListener method getAlreadySelectedGpx.
@NonNull
private List<String> getAlreadySelectedGpx() {
GpxSelectionHelper selectedGpxHelper = mapActivity.getMyApplication().getSelectedGpxHelper();
List<SelectedGpxFile> selectedGpxFiles = selectedGpxHelper.getSelectedGPXFiles();
List<String> files = GpxUiHelper.getSelectedTrackPaths(mapActivity.getMyApplication());
if (selectedGpxFiles.isEmpty()) {
Map<GPXFile, Long> fls = selectedGpxHelper.getSelectedGpxFilesBackUp();
for (Map.Entry<GPXFile, Long> f : fls.entrySet()) {
if (!Algorithms.isEmpty(f.getKey().path)) {
File file = new File(f.getKey().path);
if (file.exists() && !file.isDirectory()) {
files.add(f.getKey().path);
}
}
}
}
return files;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class WptPtMenuController method getTypeStr.
@NonNull
@Override
public String getTypeStr() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
GpxSelectionHelper helper = mapActivity.getMyApplication().getSelectedGpxHelper();
SelectedGpxFile selectedGpxFile = helper.getSelectedGPXFile(wpt);
StringBuilder sb = new StringBuilder();
sb.append(mapActivity.getString(R.string.shared_string_waypoint));
sb.append(", ");
if (selectedGpxFile != null) {
File file = new File(selectedGpxFile.getGpxFile().path);
String gpxName = file.getName().replace(IndexConstants.GPX_FILE_EXT, "").replace("/", " ").replace("_", " ");
sb.append(gpxName);
}
return sb.toString();
} else {
return "";
}
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class AvailableGPXFragment method getGpxTrackAnalysis.
@Nullable
public static GPXTrackAnalysis getGpxTrackAnalysis(@NonNull GpxInfo gpxInfo, @NonNull OsmandApplication app, @Nullable final GpxInfoViewCallback callback) {
SelectedGpxFile sgpx = getSelectedGpxFile(gpxInfo, app);
GPXTrackAnalysis analysis = null;
if (sgpx != null && sgpx.isLoaded()) {
analysis = sgpx.getTrackAnalysis(app);
} else if (gpxInfo.currentlyRecordingTrack) {
analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis(app);
} else if (gpxInfo.file != null) {
GpxDataItemCallback analyserCallback = null;
if (callback != null) {
analyserCallback = new GpxDataItemCallback() {
@Override
public boolean isCancelled() {
return callback.isCancelled();
}
@Override
public void onGpxDataItemReady(GpxDataItem item) {
callback.onGpxDataItemChanged(item);
}
};
}
GpxDataItem dataItem = app.getGpxDbHelper().getItem(gpxInfo.file, analyserCallback);
if (dataItem != null) {
analysis = dataItem.getAnalysis();
}
}
return analysis;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class SplitSegmentDialogFragment method updateHeader.
private void updateHeader() {
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
if (getGpx() != null && !getGpx().showCurrentTrack && adapter.getCount() > 0) {
setupSplitIntervalView(splitIntervalView);
if (options.size() == 0) {
prepareSplitIntervalAdapterData();
}
updateSplitIntervalView(splitIntervalView);
splitIntervalView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final ListPopupWindow popup = new ListPopupWindow(v.getContext());
popup.setAnchorView(splitIntervalView);
popup.setContentWidth(AndroidUtils.dpToPx(app, 200f));
popup.setModal(true);
popup.setDropDownGravity(Gravity.RIGHT | Gravity.TOP);
popup.setVerticalOffset(AndroidUtils.dpToPx(app, -48f));
popup.setHorizontalOffset(AndroidUtils.dpToPx(app, -6f));
popup.setAdapter(new ArrayAdapter<>(v.getContext(), R.layout.popup_list_text_item, options));
popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedSplitInterval = position;
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(getGpx(), true, false);
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, sf);
}
popup.dismiss();
updateSplitIntervalView(splitIntervalView);
}
});
popup.show();
}
});
splitIntervalView.setVisibility(View.VISIBLE);
} else {
splitIntervalView.setVisibility(View.GONE);
}
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.
the class GPXAction method setupGpxTrackInfo.
private void setupGpxTrackInfo(@NonNull final View container, @NonNull final OsmandApplication app) {
String gpxFilePath = getSelectedGpxFilePath(false);
if (gpxFilePath == null) {
return;
}
View trackInfoContainer = container.findViewById(R.id.selected_track_file_container);
boolean currentTrack = gpxFilePath.isEmpty();
File file = new File(gpxFilePath);
String gpxName = currentTrack ? app.getString(R.string.current_track) : GpxUiHelper.getGpxTitle(file.getName());
SelectedGpxFile selectedGpxFile = currentTrack ? app.getSavingTrackHelper().getCurrentTrack() : app.getSelectedGpxHelper().getSelectedFileByPath(gpxFilePath);
if (selectedGpxFile != null) {
setupGpxTrackInfo(trackInfoContainer, gpxName, selectedGpxFile.getTrackAnalysis(app), app);
} else {
GpxDataItem gpxDataItem = app.getGpxDbHelper().getItem(file, new GpxDataItemCallback() {
@Override
public boolean isCancelled() {
return false;
}
@Override
public void onGpxDataItemReady(GpxDataItem item) {
if (item != null && item.getAnalysis() != null) {
setupGpxTrackInfo(trackInfoContainer, gpxName, item.getAnalysis(), app);
}
}
});
if (gpxDataItem != null && gpxDataItem.getAnalysis() != null) {
setupGpxTrackInfo(trackInfoContainer, gpxName, gpxDataItem.getAnalysis(), app);
}
}
}
Aggregations