Search in sources :

Example 1 with DisplayGroupsHolder

use of net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder 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 2 with DisplayGroupsHolder

use of net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder in project Osmand by osmandapp.

the class DisplayGroupsBottomSheet method initSelectableItems.

private void initSelectableItems() {
    List<GpxDisplayGroup> displayGroups = displayHelper.getPointsOriginalGroups();
    DisplayGroupsHolder groupsHolder = DisplayPointsGroupsHelper.getGroups(app, displayGroups, null);
    uiItems.clear();
    for (GpxDisplayGroup group : groupsHolder.groups) {
        if (group.getType() != GpxDisplayItemType.TRACK_POINTS) {
            continue;
        }
        SelectableItem<GpxDisplayGroup> uiItem = new SelectableItem<>();
        List<GpxDisplayItem> groupItems = groupsHolder.itemGroups.get(group);
        String categoryName = group.getName();
        if (TextUtils.isEmpty(categoryName)) {
            categoryName = app.getString(R.string.shared_string_gpx_points);
        }
        uiItem.setTitle(categoryName);
        uiItem.setColor(group.getColor());
        int size = groupItems != null ? groupItems.size() : 0;
        uiItem.setDescription(String.valueOf(size));
        uiItem.setObject(group);
        uiItems.add(uiItem);
    }
}
Also used : GpxDisplayGroup(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup) DisplayGroupsHolder(net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder) SelectableItem(net.osmand.plus.base.SelectionBottomSheet.SelectableItem) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)

Example 3 with DisplayGroupsHolder

use of net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder in project Osmand by osmandapp.

the class TrackMenuFragment method fitSelectedPointsGroupOnMap.

private void fitSelectedPointsGroupOnMap(GpxDisplayGroup group) {
    DisplayGroupsHolder groupsHolder = getDisplayGroupsHolder();
    List<GpxDisplayItem> points = groupsHolder.getItemsByGroupName(group.getName());
    if (points != null) {
        QuadRect pointsRect = new QuadRect();
        for (GpxDisplayItem point : points) {
            GPXUtilities.updateQR(pointsRect, point.locationStart, 0, 0);
        }
        adjustMapPosition(pointsRect);
    }
}
Also used : DisplayGroupsHolder(net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) QuadRect(net.osmand.data.QuadRect)

Example 4 with DisplayGroupsHolder

use of net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder in project Osmand by osmandapp.

the class TrackMenuFragment method updateDisplayGroupsWidget.

public void updateDisplayGroupsWidget() {
    boolean widgetVisible = hasPointsGroups() && !shouldShowWidgets();
    if (widgetVisible) {
        DisplayGroupsHolder displayGroupsHolder = getDisplayGroupsHolder();
        int visible = displayGroupsHolder.getVisibleTrackGroupsNumber(selectedGpxFile);
        int total = displayGroupsHolder.getTotalTrackGroupsNumber();
        TextView indication = displayGroupsWidget.findViewById(R.id.visible_display_groups_size);
        boolean hasRouteGroupsOnly = total == 0;
        if (hasRouteGroupsOnly) {
            indication.setText("0");
        } else {
            indication.setText(getString(R.string.ltr_or_rtl_combine_via_slash, String.valueOf(visible), String.valueOf(total)));
        }
    }
    AndroidUiHelper.updateVisibility(displayGroupsWidget, widgetVisible);
}
Also used : DisplayGroupsHolder(net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder) TextView(android.widget.TextView) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) NewGpxPoint(net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)

Aggregations

DisplayGroupsHolder (net.osmand.plus.track.helpers.DisplayPointsGroupsHelper.DisplayGroupsHolder)4 GpxDisplayItem (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)3 GpxDisplayGroup (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup)2 TextView (android.widget.TextView)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 WptPt (net.osmand.GPXUtilities.WptPt)1 QuadRect (net.osmand.data.QuadRect)1 SelectableItem (net.osmand.plus.base.SelectionBottomSheet.SelectableItem)1 SelectedGpxPoint (net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint)1 NewGpxPoint (net.osmand.plus.views.AddGpxPointBottomSheetHelper.NewGpxPoint)1