Search in sources :

Example 26 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class WptPtMenuBuilder method buildWaypointsView.

private void buildWaypointsView(View view) {
    GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
    SelectedGpxFile selectedGpxFile = gpxSelectionHelper.getSelectedGPXFile(wpt);
    if (selectedGpxFile != null) {
        List<WptPt> points = selectedGpxFile.getGpxFile().getPoints();
        GPXUtilities.GPXFile gpx = selectedGpxFile.getGpxFile();
        if (points.size() > 0) {
            String title = view.getContext().getString(R.string.context_menu_points_of_group);
            File file = new File(gpx.path);
            String gpxName = file.getName().replace(".gpx", "").replace("/", " ").replace("_", " ");
            int color = getPointColor(wpt, getFileColor(selectedGpxFile));
            buildRow(view, app.getIconsCache().getPaintedIcon(R.drawable.ic_type_waypoints_group, color), null, title, 0, gpxName, true, getCollapsableWaypointsView(view.getContext(), true, gpx, wpt), false, 0, false, null, false);
        }
    }
}
Also used : WptPt(net.osmand.plus.GPXUtilities.WptPt) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) File(java.io.File) GPXUtilities(net.osmand.plus.GPXUtilities)

Example 27 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class AddTracksGroupBottomSheetDialogFragment method createMapMarkersSyncGroup.

private MapMarkersGroup createMapMarkersSyncGroup(OsmandApplication app, GpxDataItem gpxDataItem) {
    GpxSelectionHelper gpxSelectionHelper = app.getSelectedGpxHelper();
    File gpx = gpxDataItem.getFile();
    SelectedGpxFile selectedGpxFile = gpxSelectionHelper.getSelectedFileByPath(gpx.getAbsolutePath());
    if (selectedGpxFile == null) {
        GPXFile res = GPXUtilities.loadGPXFile(app, gpx);
        gpxSelectionHelper.selectGpxFile(res, true, false);
    }
    return getMyApplication().getMapMarkersHelper().getOrCreateGroup(gpx);
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File)

Example 28 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class GpxUiHelper method selectSingleGPXFile.

public static AlertDialog selectSingleGPXFile(final Activity activity, boolean showCurrentGpx, final CallbackWithObject<GPXFile[]> callbackWithObject) {
    OsmandApplication app = (OsmandApplication) activity.getApplication();
    int gpxDirLength = app.getAppPath(IndexConstants.GPX_INDEX_DIR).getAbsolutePath().length();
    List<SelectedGpxFile> selectedGpxFiles = app.getSelectedGpxHelper().getSelectedGPXFiles();
    final List<GPXInfo> list = new ArrayList<>(selectedGpxFiles.size() + 1);
    if (OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) == null) {
        showCurrentGpx = false;
    }
    if (!selectedGpxFiles.isEmpty() || showCurrentGpx) {
        if (showCurrentGpx) {
            list.add(new GPXInfo(activity.getString(R.string.shared_string_currently_recording_track), 0, 0));
        }
        for (SelectedGpxFile selectedGpx : selectedGpxFiles) {
            if (!selectedGpx.getGpxFile().showCurrentTrack) {
                list.add(new GPXInfo(selectedGpx.getGpxFile().path.substring(gpxDirLength + 1), selectedGpx.getGpxFile().modifiedTime, 0));
            }
        }
        final ContextMenuAdapter adapter = createGpxContextMenuAdapter(list, null, showCurrentGpx);
        return createSingleChoiceDialog(activity, showCurrentGpx, callbackWithObject, list, adapter);
    }
    return null;
}
Also used : ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) OsmandApplication(net.osmand.plus.OsmandApplication) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ArrayList(java.util.ArrayList) SuppressLint(android.annotation.SuppressLint) OsmandMonitoringPlugin(net.osmand.plus.monitoring.OsmandMonitoringPlugin)

Example 29 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class MapMarkersHelper method getGroupsForDisplayedGpx.

@NonNull
public List<MapMarkersGroup> getGroupsForDisplayedGpx() {
    List<MapMarkersGroup> res = new ArrayList<>();
    List<SelectedGpxFile> selectedGpxFiles = ctx.getSelectedGpxHelper().getSelectedGPXFiles();
    for (SelectedGpxFile selected : selectedGpxFiles) {
        MapMarkersGroup group = getOrCreateGroup(new File(selected.getGpxFile().path));
        if (!isGroupSynced(group.getId())) {
            group.disabled = true;
            createHeaderInGroup(group);
            res.add(group);
        }
    }
    return res;
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ArrayList(java.util.ArrayList) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File) NonNull(android.support.annotation.NonNull)

Example 30 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile in project Osmand by osmandapp.

the class OsmandAidlApi method hideGpx.

boolean hideGpx(String fileName) {
    if (!Algorithms.isEmpty(fileName)) {
        SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByName(fileName);
        if (selectedGpxFile != null) {
            app.getSelectedGpxHelper().selectGpxFile(selectedGpxFile.getGpxFile(), false, false);
            refreshMap();
            return true;
        }
    }
    return false;
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ASelectedGpxFile(net.osmand.aidl.gpx.ASelectedGpxFile)

Aggregations

SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)35 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)18 File (java.io.File)13 ArrayList (java.util.ArrayList)9 View (android.view.View)7 GpxSelectionHelper (net.osmand.plus.GpxSelectionHelper)7 OsmandApplication (net.osmand.plus.OsmandApplication)7 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 GpxDataItem (net.osmand.plus.GPXDatabase.GpxDataItem)6 WptPt (net.osmand.plus.GPXUtilities.WptPt)6 Paint (android.graphics.Paint)5 AdapterView (android.widget.AdapterView)4 ArrayAdapter (android.widget.ArrayAdapter)4 GpxDisplayGroup (net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup)4 SuppressLint (android.annotation.SuppressLint)3 DialogInterface (android.content.DialogInterface)3 AlertDialog (android.support.v7.app.AlertDialog)3 ViewGroup (android.view.ViewGroup)3 CompoundButton (android.widget.CompoundButton)3