use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class SegmentsCard method updateLocationOnMap.
private void updateLocationOnMap(@NonNull List<GpxDisplayItem> displayItems) {
if (gpxPoint != null) {
for (GpxDisplayItem item : displayItems) {
TrkSegment segment = GPXItemPagerAdapter.getSegmentForAnalysis(item, item.analysis);
if (segment != null && (segment.points.contains(gpxPoint.getSelectedPoint()) || segment.points.contains(gpxPoint.getPrevPoint()) && segment.points.contains(gpxPoint.getNextPoint()))) {
item.locationOnMap = gpxPoint.getSelectedPoint();
listener.onPointSelected(segment, item.locationOnMap.lat, item.locationOnMap.lon);
}
}
}
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class TrackPointsCard method onChildClick.
@Override
public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
GpxDisplayItem item = adapter.getChild(groupPosition, childPosition);
if (item != null && item.locationStart != null) {
notifyButtonPressed(OPEN_WAYPOINT_INDEX);
LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
PointDescription description = new PointDescription(PointDescription.POINT_TYPE_WPT, item.name);
MapContextMenu contextMenu = mapActivity.getContextMenu();
contextMenu.setCenterMarker(true);
contextMenu.show(location, description, item.locationStart);
}
return true;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class DisplayPointsGroupsHelper method filterItems.
private Map<String, List<GpxDisplayItem>> filterItems(Map<String, List<GpxDisplayItem>> itemsMap, Set<?> filteredItems) {
Map<String, List<GpxDisplayItem>> itemsMapFiltered = new HashMap<>();
for (Entry<String, List<GpxDisplayItem>> e : itemsMap.entrySet()) {
String category = e.getKey();
List<GpxDisplayItem> items = e.getValue();
if (filteredItems.contains(category)) {
itemsMapFiltered.put(category, items);
} else {
for (GpxDisplayItem i : items) {
if (filteredItems.contains(i)) {
List<GpxDisplayItem> itemsFiltered = itemsMapFiltered.get(category);
if (itemsFiltered == null) {
itemsFiltered = new ArrayList<>();
itemsMapFiltered.put(category, itemsFiltered);
}
itemsFiltered.add(i);
}
}
}
}
return itemsMapFiltered;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class DisplayPointsGroupsHelper method setCollectedItems.
private void setCollectedItems(GpxDisplayGroup group, Map<String, List<GpxDisplayItem>> itemsMap) {
List<String> categories = new ArrayList<>(itemsMap.keySet());
Collections.sort(categories, comparator);
for (String category : categories) {
List<GpxDisplayItem> values = itemsMap.get(category);
GpxDisplayGroup headerGroup = group.cloneInstance();
headerGroup.setName(category);
for (GpxDisplayItem i : values) {
if (i.locationStart != null && i.locationStart.getColor() != 0) {
headerGroup.setColor(i.locationStart.getColor(group.getColor()));
break;
}
}
List<GpxDisplayItem> headerGroupItems = headerGroup.getModifiableList();
headerGroupItems.clear();
headerGroupItems.addAll(values);
itemGroups.put(headerGroup, values);
this.groups.add(headerGroup);
}
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class GpxUiHelper method makeGpxDisplayItem.
public static GpxDisplayItem makeGpxDisplayItem(@NonNull OsmandApplication app, @NonNull GPXFile gpxFile, @NonNull ChartPointLayer chartPointLayer) {
GpxDisplayGroup group = null;
if (!Algorithms.isEmpty(gpxFile.tracks)) {
GpxSelectionHelper helper = app.getSelectedGpxHelper();
String groupName = helper.getGroupName(gpxFile);
group = helper.buildGpxDisplayGroup(gpxFile, 0, groupName);
}
if (group != null && group.getModifiableList().size() > 0) {
GpxDisplayItem gpxItem = group.getModifiableList().get(0);
if (gpxItem != null) {
gpxItem.chartPointLayer = chartPointLayer;
}
return gpxItem;
}
return null;
}
Aggregations