Search in sources :

Example 6 with GpxDataItem

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;
}
Also used : ILineDataSet(com.github.mikephil.charting.interfaces.datasets.ILineDataSet) GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) GPXFile(net.osmand.GPXUtilities.GPXFile)

Example 7 with GpxDataItem

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;
}
Also used : SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) GpxDataItemCallback(net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback) GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) GPXTrackAnalysis(net.osmand.GPXUtilities.GPXTrackAnalysis) Nullable(androidx.annotation.Nullable)

Example 8 with GpxDataItem

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);
        }
    }
}
Also used : SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) GpxDataItemCallback(net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback) GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) GPXFile(net.osmand.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) File(java.io.File)

Example 9 with GpxDataItem

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;
}
Also used : AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) MapMarker(net.osmand.plus.mapmarkers.MapMarker) OsmNotesPoint(net.osmand.plus.plugins.osmedit.data.OsmNotesPoint) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) OpenstreetmapPoint(net.osmand.plus.plugins.osmedit.data.OpenstreetmapPoint) GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) List(java.util.List) ArrayList(java.util.ArrayList) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) ExportSettingsType(net.osmand.plus.settings.backend.ExportSettingsType) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) HistoryEntry(net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) File(java.io.File)

Example 10 with GpxDataItem

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;
}
Also used : GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) GPXFile(net.osmand.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) ASqliteDbFile(net.osmand.aidl.tiles.ASqliteDbFile) File(java.io.File) ASelectedGpxFile(net.osmand.aidl.gpx.ASelectedGpxFile) AGpxFile(net.osmand.aidl.gpx.AGpxFile)

Aggregations

GpxDataItem (net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem)28 File (java.io.File)18 GPXFile (net.osmand.GPXUtilities.GPXFile)18 SelectedGpxFile (net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile)16 GPXTrackAnalysis (net.osmand.GPXUtilities.GPXTrackAnalysis)8 GpxDataItemCallback (net.osmand.plus.track.helpers.GpxDbHelper.GpxDataItemCallback)6 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 View (android.view.View)4 AGpxFile (net.osmand.aidl.gpx.AGpxFile)4 ASelectedGpxFile (net.osmand.aidl.gpx.ASelectedGpxFile)4 ASqliteDbFile (net.osmand.aidl.tiles.ASqliteDbFile)4 SuppressLint (android.annotation.SuppressLint)3 ArrayList (java.util.ArrayList)3 OsmandApplication (net.osmand.plus.OsmandApplication)3 Bundle (android.os.Bundle)2 SpannableString (android.text.SpannableString)2 LinearLayout (android.widget.LinearLayout)2 Nullable (androidx.annotation.Nullable)2 List (java.util.List)2