Search in sources :

Example 1 with GpxDisplayGroup

use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup 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 2 with GpxDisplayGroup

use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup 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 3 with GpxDisplayGroup

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

the class SplitSegmentDialogFragment method getOverviewSegment.

private GpxDisplayItem getOverviewSegment() {
    List<GpxDisplayGroup> result = getTrackActivity().getGpxFile(false);
    GpxDisplayItem overviewSegment = null;
    if (result.size() > 0) {
        overviewSegment = result.get(0).getModifiableList().get(0);
    }
    return overviewSegment;
}
Also used : GpxDisplayGroup(net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup) GpxDisplayItem(net.osmand.plus.GpxSelectionHelper.GpxDisplayItem)

Example 4 with GpxDisplayGroup

use of net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup 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(getActivity());
                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<>(getTrackActivity(), 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;
                        GpxSelectionHelper.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);
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup) ListPopupWindow(android.support.v7.widget.ListPopupWindow) AdapterView(android.widget.AdapterView) GpxSelectionHelper(net.osmand.plus.GpxSelectionHelper) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) AbsListView(android.widget.AbsListView) TextView(android.widget.TextView) ListView(android.widget.ListView) ArrayAdapter(android.widget.ArrayAdapter)

Example 5 with GpxDisplayGroup

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

the class TrackSegmentFragment method setupSplitIntervalView.

private void setupSplitIntervalView(View view) {
    final TextView title = (TextView) view.findViewById(R.id.split_interval_title);
    final TextView text = (TextView) view.findViewById(R.id.split_interval_text);
    final ImageView img = (ImageView) view.findViewById(R.id.split_interval_arrow);
    int colorId;
    final List<GpxDisplayGroup> groups = getDisplayGroups();
    if (groups.size() > 0) {
        colorId = app.getSettings().isLightContent() ? R.color.primary_text_light : R.color.primary_text_dark;
    } else {
        colorId = app.getSettings().isLightContent() ? R.color.secondary_text_light : R.color.secondary_text_dark;
    }
    int color = app.getResources().getColor(colorId);
    title.setTextColor(color);
    text.setTextColor(color);
    img.setImageDrawable(app.getIconsCache().getIcon(R.drawable.ic_action_arrow_drop_down, colorId));
}
Also used : GpxDisplayGroup(net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup) TextView(android.widget.TextView) ImageView(android.widget.ImageView) Paint(android.graphics.Paint)

Aggregations

GpxDisplayGroup (net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup)10 Paint (android.graphics.Paint)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 SelectedGpxFile (net.osmand.plus.GpxSelectionHelper.SelectedGpxFile)4 GPXFile (net.osmand.plus.GPXUtilities.GPXFile)3 GpxDisplayItem (net.osmand.plus.GpxSelectionHelper.GpxDisplayItem)3 ListPopupWindow (android.support.v7.widget.ListPopupWindow)2 View (android.view.View)2 AbsListView (android.widget.AbsListView)2 AdapterView (android.widget.AdapterView)2 ArrayAdapter (android.widget.ArrayAdapter)2 ListView (android.widget.ListView)2 ArrayList (java.util.ArrayList)2 GpxDataItem (net.osmand.plus.GPXDatabase.GpxDataItem)2 WptPt (net.osmand.plus.GPXUtilities.WptPt)2 GpxSelectionHelper (net.osmand.plus.GpxSelectionHelper)2 SwitchCompat (android.support.v7.widget.SwitchCompat)1 DisplayMetrics (android.util.DisplayMetrics)1 WindowManager (android.view.WindowManager)1