Search in sources :

Example 6 with GpxDisplayGroup

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

the class SplitSegmentDialogFragment method getSplitSegments.

@NonNull
private List<GpxDisplayItem> getSplitSegments() {
    List<GpxDisplayItem> splitSegments = new ArrayList<>();
    List<GpxDisplayGroup> result = displayHelper.getGpxFile(true);
    if (result != null && result.size() > 0 && trkSegment.points.size() > 0) {
        for (GpxDisplayGroup group : result) {
            splitSegments.addAll(collectDisplayItemsFromGroup(group));
        }
    }
    return splitSegments;
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) TIntArrayList(gnu.trove.list.array.TIntArrayList) ArrayList(java.util.ArrayList) NonNull(androidx.annotation.NonNull)

Example 7 with GpxDisplayGroup

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

the class TrackPointsAdapter method synchronizeGroups.

public void synchronizeGroups(@NonNull List<GpxDisplayGroup> displayGroups) {
    groups.clear();
    pointsGroups.clear();
    DisplayGroupsHolder groupsHolder = DisplayPointsGroupsHelper.getGroups(app, displayGroups, null);
    groups.addAll(groupsHolder.groups);
    for (Map.Entry<GpxDisplayGroup, List<GpxDisplayItem>> entry : groupsHolder.itemGroups.entrySet()) {
        List<WptPt> points = new ArrayList<>();
        for (GpxDisplayItem item : entry.getValue()) {
            points.add(item.locationStart);
        }
        pointsGroups.put(entry.getKey(), points);
    }
    notifyDataSetChanged();
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) WptPt(net.osmand.GPXUtilities.WptPt) DisplayGroupsHolder(net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder) ArrayList(java.util.ArrayList) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) ArrayList(java.util.ArrayList) List(java.util.List) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Example 8 with GpxDisplayGroup

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

the class TrackPointsAdapter method getGroupView.

@Override
public View getGroupView(int groupPosition, boolean isExpanded, View view, ViewGroup parent) {
    if (view == null) {
        view = inflater.inflate(R.layout.points_group_item, parent, false);
    }
    GpxDisplayGroup group = getGroup(groupPosition);
    List<WptPt> points = pointsGroups.get(group);
    String name = group.getName();
    String nameToDisplay = Algorithms.isEmpty(name) ? app.getString(R.string.shared_string_gpx_points) : name;
    TextView title = view.findViewById(R.id.title);
    title.setText(nameToDisplay);
    int selectedCount = 0;
    for (WptPt point : points) {
        if (selectedPoints.contains(point)) {
            selectedCount++;
        }
    }
    String count = app.getString(R.string.ltr_or_rtl_combine_via_slash, String.valueOf(selectedCount), String.valueOf(points.size()));
    TextView description = view.findViewById(R.id.description);
    description.setText(count);
    CompoundButton compoundButton = view.findViewById(R.id.compound_button);
    compoundButton.setChecked(selectedPoints.containsAll(points));
    UiUtilities.setupCompoundButton(compoundButton, nightMode, CompoundButtonType.GLOBAL);
    view.findViewById(R.id.compound_container).setOnClickListener(v -> {
        boolean selected = !compoundButton.isChecked();
        if (listener != null) {
            listener.onCategorySelected(points, selected);
        }
        notifyDataSetChanged();
    });
    int color = group.getColor();
    if (color == 0) {
        color = ContextCompat.getColor(app, R.color.gpx_color_point);
    }
    ImageView groupImage = view.findViewById(R.id.icon);
    groupImage.setImageDrawable(uiUtilities.getPaintedIcon(R.drawable.ic_action_folder, color));
    adjustIndicator(app, groupPosition, isExpanded, view, !nightMode);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_top_divider), true);
    AndroidUiHelper.updateVisibility(view.findViewById(R.id.card_bottom_divider), !isExpanded);
    return view;
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) WptPt(net.osmand.GPXUtilities.WptPt) TextView(android.widget.TextView) ImageView(android.widget.ImageView) CompoundButton(android.widget.CompoundButton)

Example 9 with GpxDisplayGroup

use of net.osmand.plus.track.helpers.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() >= START_ZOOM) {
        // request to load
        OsmandApplication app = view.getApplication();
        for (SelectedGpxFile selectedGpxFile : selectedGPXFiles) {
            List<GpxDisplayGroup> groups = selectedGpxFile.getDisplayGroups(app);
            if (!Algorithms.isEmpty(groups)) {
                int color = getTrackColor(selectedGpxFile.getGpxFile(), cachedColor);
                paintInnerRect.setColor(color);
                paintInnerRect.setAlpha(179);
                int contrastColor = ColorUtilities.getContrastColor(app, color, false);
                paintTextIcon.setColor(contrastColor);
                paintOuterRect.setColor(contrastColor);
                List<GpxDisplayItem> items = groups.get(0).getModifiableList();
                drawSplitItems(canvas, tileBox, items, settings);
            }
        }
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) OsmandApplication(net.osmand.plus.OsmandApplication) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) Paint(android.graphics.Paint) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)

Example 10 with GpxDisplayGroup

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

the class PointsGroupsCard method updateContent.

@Override
protected void updateContent() {
    HorizontalChipsView chipsView = view.findViewById(R.id.chips_view);
    ArrayList<ChipItem> items = new ArrayList<>();
    ChipItem categoryAll = new ChipItem(app.getString(R.string.shared_string_all));
    categoryAll.title = categoryAll.id;
    items.add(categoryAll);
    int iconSizePx = getDimen(R.dimen.poi_icon_size);
    int iconColorId = ColorUtilities.getSecondaryIconColorId(nightMode);
    int smallPadding = getDimen(R.dimen.content_padding_small);
    for (GpxDisplayGroup group : displayGroups) {
        String categoryDisplayName = Algorithms.isEmpty(group.getName()) ? app.getString(R.string.shared_string_gpx_points) : group.getName();
        ChipItem item = new ChipItem(categoryDisplayName);
        item.title = categoryDisplayName;
        item.tag = group;
        item.onAfterViewBoundCallback = (chip, holder) -> {
            if (selectedGpxFile.isGroupHidden(chip.id)) {
                Drawable image = getColoredIcon(R.drawable.ic_action_hide_16, iconColorId);
                holder.image.setImageDrawable(image);
                holder.image.setVisibility(View.VISIBLE);
                LayoutParams imgLayoutParams = holder.image.getLayoutParams();
                imgLayoutParams.height = iconSizePx;
                imgLayoutParams.width = iconSizePx;
                int top = holder.container.getPaddingTop();
                int bottom = holder.container.getPaddingBottom();
                holder.container.setPadding(smallPadding, top, smallPadding, bottom);
            }
        };
        items.add(item);
    }
    chipsView.setItems(items);
    String selectedId = categoryAll.id;
    if (selectedGroup != null) {
        selectedId = selectedGroup.getName();
        if (Algorithms.isEmpty(selectedId)) {
            selectedId = app.getString(R.string.shared_string_gpx_points);
        }
    }
    ChipItem selected = chipsView.getChipById(selectedId);
    chipsView.setSelected(selected);
    chipsView.setOnSelectChipListener(chip -> {
        selectedGroup = (GpxDisplayGroup) chip.tag;
        CardListener listener = getListener();
        if (listener != null) {
            listener.onCardButtonPressed(PointsGroupsCard.this, SELECT_GROUP_INDEX);
        }
        chipsView.smoothScrollTo(chip);
        return true;
    });
    chipsView.notifyDataSetChanged();
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) LayoutParams(android.view.ViewGroup.LayoutParams) HorizontalChipsView(net.osmand.plus.widgets.chips.HorizontalChipsView) ArrayList(java.util.ArrayList) Drawable(android.graphics.drawable.Drawable) ChipItem(net.osmand.plus.widgets.chips.ChipItem)

Aggregations

GpxDisplayGroup (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup)22 ArrayList (java.util.ArrayList)7 GpxDisplayItem (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)7 ImageView (android.widget.ImageView)6 TextView (android.widget.TextView)6 SelectedGpxFile (net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile)5 CompoundButton (android.widget.CompoundButton)4 View (android.view.View)3 GPXFile (net.osmand.GPXUtilities.GPXFile)3 WptPt (net.osmand.GPXUtilities.WptPt)3 Paint (android.graphics.Paint)2 AbsListView (android.widget.AbsListView)2 File (java.io.File)2 List (java.util.List)2 OsmandApplication (net.osmand.plus.OsmandApplication)2 DisplayGroupsHolder (net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder)2 DialogInterface (android.content.DialogInterface)1 Drawable (android.graphics.drawable.Drawable)1 SpannableString (android.text.SpannableString)1 OnClickListener (android.view.View.OnClickListener)1