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;
}
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();
}
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;
}
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);
}
}
}
}
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();
}
Aggregations