use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class GPXItemPagerAdapter method getDataSets.
private List<ILineDataSet> getDataSets(LineChart chart, GPXTabItemType tabType, LineGraphType firstType, LineGraphType secondType) {
List<ILineDataSet> dataSets = dataSetsMap.get(tabType);
boolean withoutGaps = true;
if (isShowCurrentTrack()) {
GPXFile gpxFile = displayHelper.getGpx();
withoutGaps = !app.getSavingTrackHelper().getCurrentTrack().isJoinSegments() && gpxFile != null && (Algorithms.isEmpty(gpxFile.tracks) || gpxFile.tracks.get(0).generalTrack);
} else if (gpxItem != null) {
GpxDataItem gpxDataItem = displayHelper.getGpxDataItem();
withoutGaps = gpxItem.isGeneralTrack() && gpxDataItem != null && !gpxDataItem.isJoinSegments();
}
if (chart != null && analysis != null) {
dataSets = GpxUiHelper.getDataSets(chart, app, analysis, firstType, secondType, withoutGaps);
if (!Algorithms.isEmpty(dataSets)) {
dataSetsMap.remove(tabType);
}
dataSetsMap.put(tabType, dataSets);
}
return dataSets;
}
use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem 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.GPXDatabase.GpxDataItem 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);
}
}
}
use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class SettingsHelper method getMyPlacesItems.
private Map<ExportSettingsType, List<?>> getMyPlacesItems(@Nullable List<ExportSettingsType> settingsTypes, boolean addEmptyItems) {
Map<ExportSettingsType, List<?>> myPlacesItems = new LinkedHashMap<>();
List<FavoriteGroup> favoriteGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.FAVORITES) ? app.getFavoritesHelper().getFavoriteGroups() : Collections.emptyList();
if (!favoriteGroups.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.FAVORITES, favoriteGroups);
}
List<GpxDataItem> gpxItems = settingsTypes == null || settingsTypes.contains(ExportSettingsType.TRACKS) ? app.getGpxDbHelper().getItems() : Collections.emptyList();
if (!gpxItems.isEmpty() || addEmptyItems) {
List<File> files = new ArrayList<>();
for (GpxDataItem gpxItem : gpxItems) {
File file = gpxItem.getFile();
if (file.exists() && !file.isDirectory()) {
files.add(file);
}
}
if (!files.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.TRACKS, files);
}
}
OsmEditingPlugin osmEditingPlugin = OsmandPlugin.getActivePlugin(OsmEditingPlugin.class);
if (osmEditingPlugin != null) {
List<OsmNotesPoint> notesPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_NOTES) ? osmEditingPlugin.getDBBug().getOsmbugsPoints() : Collections.emptyList();
if (!notesPointList.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.OSM_NOTES, notesPointList);
}
List<OpenstreetmapPoint> editsPointList = settingsTypes == null || settingsTypes.contains(ExportSettingsType.OSM_EDITS) ? osmEditingPlugin.getDBPOI().getOpenstreetmapPoints() : Collections.emptyList();
if (!editsPointList.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.OSM_EDITS, editsPointList);
}
}
AudioVideoNotesPlugin avNotesPlugin = OsmandPlugin.getActivePlugin(AudioVideoNotesPlugin.class);
if (avNotesPlugin != null) {
List<File> files = new ArrayList<>();
if (settingsTypes == null || settingsTypes.contains(ExportSettingsType.MULTIMEDIA_NOTES)) {
for (Recording rec : avNotesPlugin.getAllRecordings()) {
File file = rec.getFile();
if (file != null && file.exists()) {
files.add(file);
}
}
}
if (!files.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.MULTIMEDIA_NOTES, files);
}
}
List<MapMarker> mapMarkers = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ACTIVE_MARKERS) ? app.getMapMarkersHelper().getMapMarkers() : Collections.emptyList();
if (!mapMarkers.isEmpty() || addEmptyItems) {
String name = app.getString(R.string.map_markers);
String groupId = ExportSettingsType.ACTIVE_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
markersGroup.setMarkers(mapMarkers);
myPlacesItems.put(ExportSettingsType.ACTIVE_MARKERS, Collections.singletonList(markersGroup));
}
List<MapMarker> markersHistory = settingsTypes == null || settingsTypes.contains(ExportSettingsType.HISTORY_MARKERS) ? app.getMapMarkersHelper().getMapMarkersHistory() : Collections.emptyList();
if (!markersHistory.isEmpty() || addEmptyItems) {
String name = app.getString(R.string.shared_string_history);
String groupId = ExportSettingsType.HISTORY_MARKERS.name();
MapMarkersGroup markersGroup = new MapMarkersGroup(groupId, name, ItineraryType.MARKERS);
markersGroup.setMarkers(markersHistory);
myPlacesItems.put(ExportSettingsType.HISTORY_MARKERS, Collections.singletonList(markersGroup));
}
List<HistoryEntry> historyEntries = settingsTypes == null || settingsTypes.contains(ExportSettingsType.SEARCH_HISTORY) ? SearchHistoryHelper.getInstance(app).getHistoryEntries(false) : Collections.emptyList();
if (!historyEntries.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.SEARCH_HISTORY, historyEntries);
}
List<MapMarkersGroup> markersGroups = settingsTypes == null || settingsTypes.contains(ExportSettingsType.ITINERARY_GROUPS) ? app.getMapMarkersHelper().getVisibleMapMarkersGroups() : Collections.emptyList();
if (!markersGroups.isEmpty() || addEmptyItems) {
myPlacesItems.put(ExportSettingsType.ITINERARY_GROUPS, markersGroups);
}
return myPlacesItems;
}
use of net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem in project Osmand by osmandapp.
the class OsmandAidlApi method removeGpx.
boolean removeGpx(String fileName) {
if (!Algorithms.isEmpty(fileName)) {
final File f = app.getAppPath(IndexConstants.GPX_INDEX_DIR + fileName);
if (f.exists()) {
GpxDataItem item = app.getGpxDbHelper().getItem(f);
if (item != null && item.isApiImported()) {
Algorithms.removeAllFiles(f);
app.getGpxDbHelper().remove(f);
return true;
}
}
}
return false;
}
Aggregations