Search in sources :

Example 1 with SelectedGpxFile

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

the class MapActivityActions method enterRoutePlanningMode.

public void enterRoutePlanningMode(final LatLon from, final PointDescription fromName) {
    final boolean useIntermediatePointsByDefault = true;
    List<SelectedGpxFile> selectedGPXFiles = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
    final List<GPXFile> gpxFiles = new ArrayList<>();
    for (SelectedGpxFile gs : selectedGPXFiles) {
        if (!gs.isShowCurrentTrack() && !gs.notShowNavigationDialog) {
            if (gs.getGpxFile().hasRtePt() || gs.getGpxFile().hasTrkPt()) {
                gpxFiles.add(gs.getGpxFile());
            }
        }
    }
    if (gpxFiles.size() > 0) {
        AlertDialog.Builder bld = new AlertDialog.Builder(mapActivity);
        if (gpxFiles.size() == 1) {
            bld.setMessage(R.string.use_displayed_track_for_navigation);
            bld.setPositiveButton(R.string.shared_string_yes, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    enterRoutePlanningModeGivenGpx(gpxFiles.get(0), from, fromName, useIntermediatePointsByDefault, true);
                }
            });
        } else {
            bld.setTitle(R.string.navigation_over_track);
            ArrayAdapter<GPXFile> adapter = new ArrayAdapter<GPXFile>(mapActivity, R.layout.drawer_list_item, gpxFiles) {

                @Override
                public View getView(int position, View convertView, ViewGroup parent) {
                    if (convertView == null) {
                        convertView = mapActivity.getLayoutInflater().inflate(R.layout.drawer_list_item, null);
                    }
                    String path = getItem(position).path;
                    String name = path.substring(path.lastIndexOf("/") + 1, path.length());
                    ((TextView) convertView.findViewById(R.id.title)).setText(name);
                    convertView.findViewById(R.id.icon).setVisibility(View.GONE);
                    convertView.findViewById(R.id.toggle_item).setVisibility(View.GONE);
                    return convertView;
                }
            };
            bld.setAdapter(adapter, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    enterRoutePlanningModeGivenGpx(gpxFiles.get(i), from, fromName, useIntermediatePointsByDefault, true);
                }
            });
        }
        bld.setNegativeButton(R.string.shared_string_no, new DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
            }
        });
        bld.show();
    } else {
        enterRoutePlanningModeGivenGpx(null, from, fromName, useIntermediatePointsByDefault, true);
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) ViewGroup(android.view.ViewGroup) GPXRouteParamsBuilder(net.osmand.plus.routing.RouteProvider.GPXRouteParamsBuilder) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) ArrayList(java.util.ArrayList) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView) OsmandMapTileView(net.osmand.plus.views.OsmandMapTileView) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) TextView(android.widget.TextView) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) ArrayAdapter(android.widget.ArrayAdapter)

Example 2 with SelectedGpxFile

use of net.osmand.plus.GpxSelectionHelper.SelectedGpxFile 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;
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup) OsmandApplication(net.osmand.plus.OsmandApplication) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) ArrayList(java.util.ArrayList) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper)

Example 3 with SelectedGpxFile

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

the class GPXLayer method drawSelectedFilesSplits.

private void drawSelectedFilesSplits(Canvas canvas, RotatedTileBox tileBox, List<SelectedGpxFile> selectedGPXFiles, DrawSettings settings) {
    if (tileBox.getZoom() >= startZoom) {
        // request to load
        for (SelectedGpxFile g : selectedGPXFiles) {
            List<GpxDisplayGroup> groups = g.getDisplayGroups();
            if (groups != null && !groups.isEmpty()) {
                GpxDataItem gpxDataItem = view.getApplication().getGpxDatabase().getItem(new File(g.getGpxFile().path));
                int color = gpxDataItem != null ? gpxDataItem.getColor() : 0;
                if (color == 0) {
                    color = g.getModifiableGpxFile().getColor(0);
                }
                if (color == 0) {
                    color = cachedColor;
                }
                paintInnerRect.setColor(color);
                paintInnerRect.setAlpha(179);
                List<GpxDisplayItem> items = groups.get(0).getModifiableList();
                drawSplitItems(canvas, tileBox, items, settings);
            }
        }
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GpxDataItem(net.osmand.plus.GPXDatabase.GpxDataItem) GpxDisplayItem(net.osmand.plus.GpxSelectionHelper.GpxDisplayItem) SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile) File(java.io.File) Paint(android.graphics.Paint)

Example 4 with SelectedGpxFile

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

the class GPXLayer method onPrepareBufferImage.

@Override
public void onPrepareBufferImage(Canvas canvas, RotatedTileBox tileBox, DrawSettings settings) {
    if (points != null) {
        updatePaints(0, false, false, settings, tileBox);
        for (TrkSegment ts : points) ts.drawRenderers(view.getZoom(), paint, canvas, tileBox);
    } else {
        List<SelectedGpxFile> selectedGPXFiles = selectedGpxHelper.getSelectedGPXFiles();
        cache.clear();
        currentTrackColor = view.getSettings().CURRENT_TRACK_COLOR.get();
        if (!selectedGPXFiles.isEmpty()) {
            drawSelectedFilesSegments(canvas, tileBox, selectedGPXFiles, settings);
            canvas.rotate(-tileBox.getRotate(), tileBox.getCenterPixelX(), tileBox.getCenterPixelY());
            if (trackChartPoints != null) {
                drawXAxisPoints(canvas, tileBox);
            }
            drawSelectedFilesSplits(canvas, tileBox, selectedGPXFiles, settings);
            drawSelectedFilesPoints(canvas, tileBox, selectedGPXFiles);
        }
        if (textLayer != null && textLayer.isVisible()) {
            textLayer.putData(this, cache);
        }
    }
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) TrkSegment(net.osmand.plus.GPXUtilities.TrkSegment)

Example 5 with SelectedGpxFile

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

the class MapContextMenu method addWptPt.

public void addWptPt() {
    String title = getTitleStr();
    if (pointDescription.isWpt() || !hasValidTitle()) {
        title = "";
    }
    final List<SelectedGpxFile> list = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFiles();
    if ((list.isEmpty() || (list.size() == 1 && list.get(0).getGpxFile().showCurrentTrack)) && OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null) {
        GPXFile gpxFile = mapActivity.getMyApplication().getSavingTrackHelper().getCurrentGpx();
        getWptPtPointEditor().add(gpxFile, latLon, title);
    } else {
        addNewWptToGPXFile(title);
    }
}
Also used : SelectedGpxFile(net.osmand.plus.GpxSelectionHelper.SelectedGpxFile) GPXFile(net.osmand.plus.GPXUtilities.GPXFile)

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