use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class SegmentsCard method updateContent.
@Override
public void updateContent() {
List<GpxDisplayItem> items = TrackDisplayHelper.flatten(displayHelper.getOriginalGroups(filterTypes));
updateLocationOnMap(items);
recyclerView = view.findViewById(R.id.recycler_view);
recyclerView.setLayoutManager(new LinearLayoutManager(activity));
recyclerView.setAdapter(new SegmentsAdapter(items));
recyclerView.setHasFixedSize(true);
LinearLayout noRoutesContainer = view.findViewById(R.id.no_routes_container);
TextViewEx createRoutesButton = view.findViewById(R.id.create_routes_btn);
TextViewEx noRoutesDescr = view.findViewById(R.id.gpx_no_routes_descr);
String args = mapActivity.getString(R.string.plan_a_route);
String noRoutesDescrText = mapActivity.getString(R.string.gpx_no_routes_descr, args);
noRoutesDescr.setText(noRoutesDescrText);
boolean showEmptyRoutes = items.isEmpty() && !selectedGpxFile.isShowCurrentTrack();
AndroidUiHelper.updateVisibility(noRoutesContainer, showEmptyRoutes);
AndroidUiHelper.updateVisibility(recyclerView, !showEmptyRoutes);
createRoutesButton.setOnClickListener(v -> SegmentsCard.this.notifyButtonPressed(EDIT_BUTTON_INDEX));
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class DisplayPointsGroupsHelper method collectItemsByCategory.
private Map<String, List<GpxDisplayItem>> collectItemsByCategory(GpxDisplayGroup group, int index) {
Map<String, List<GpxDisplayItem>> itemsMap = new HashMap<>();
for (GpxDisplayItem item : group.getModifiableList()) {
String category;
if (item.locationStart != null) {
if (group.getType() == GpxDisplayItemType.TRACK_POINTS) {
category = item.locationStart.category;
if (Algorithms.isBlank(category)) {
category = "";
}
} else {
category = app.getString(R.string.route_points) + " " + (index + 1);
}
} else {
category = "";
}
List<GpxDisplayItem> items = itemsMap.get(category);
if (items == null) {
items = new ArrayList<>();
itemsMap.put(category, items);
}
items.add(item);
}
return itemsMap;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class CopyTrackGroupToFavoritesBottomSheet method copyToFavorites.
private void copyToFavorites() {
FavouritesHelper favouritesHelper = app.getFavoritesHelper();
for (GpxDisplayItem item : group.getModifiableList()) {
if (item.locationStart != null) {
FavouritePoint fp = FavouritePoint.fromWpt(item.locationStart, app, groupName);
if (!Algorithms.isEmpty(item.description)) {
fp.setDescription(item.description);
}
favouritesHelper.addFavourite(fp, false);
}
}
favouritesHelper.saveCurrentPointsIntoFile();
Fragment fragment = getTargetFragment();
if (fragment instanceof OnGroupNameChangeListener) {
OnGroupNameChangeListener listener = (OnGroupNameChangeListener) fragment;
listener.onTrackGroupChanged();
}
dismiss();
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class MenuController method getMenuController.
public static MenuController getMenuController(@NonNull MapActivity mapActivity, @NonNull LatLon latLon, @NonNull PointDescription pointDescription, @Nullable Object object, @NonNull MenuType menuType) {
MenuController menuController = null;
if (object != null) {
if (object instanceof Amenity) {
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
} else if (object instanceof FavouritePoint) {
if (pointDescription.isParking() || (FavouritePoint.SpecialPointType.PARKING.equals(((FavouritePoint) object).getSpecialPointType()))) {
menuController = new ParkingPositionMenuController(mapActivity, pointDescription, (FavouritePoint) object);
} else {
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
}
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
} else if (object instanceof TargetPoint) {
menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
} else if (object instanceof Recording) {
menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
} else if (object instanceof OsmPoint) {
menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
} else if (object instanceof WptPt) {
menuController = WptPtMenuController.getInstance(mapActivity, pointDescription, (WptPt) object);
} else if (object instanceof DownloadMapObject) {
menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
} else if (object instanceof OpenStreetNote) {
menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
} else if (object instanceof GpxDisplayItem) {
menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
} else if (object instanceof MapMarker) {
menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
} else if (object instanceof TransportStopRoute) {
menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
} else if (object instanceof TransportStop) {
menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
} else if (object instanceof AidlMapPointWrapper) {
menuController = new AMapPointMenuController(mapActivity, pointDescription, (AidlMapPointWrapper) object);
} else if (object instanceof LatLon) {
if (pointDescription.isMyLocation()) {
menuController = new MyLocationMenuController(mapActivity, pointDescription);
}
} else if (object instanceof AvoidSpecificRoads.AvoidRoadInfo) {
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (AvoidSpecificRoads.AvoidRoadInfo) object);
} else if (object instanceof RenderedObject) {
menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
} else if (object instanceof MapillaryImage) {
menuController = new MapillaryMenuController(mapActivity, pointDescription, (MapillaryImage) object);
} else if (object instanceof SelectedGpxPoint) {
menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) object);
} else if (object instanceof Pair && ((Pair<?, ?>) object).second instanceof SelectedGpxPoint) {
menuController = new SelectedGpxMenuController(mapActivity, pointDescription, (SelectedGpxPoint) ((Pair<?, ?>) object).second);
}
}
if (menuController == null) {
menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
}
menuController.menuType = menuType;
menuController.setLatLon(latLon);
menuController.onCreated();
return menuController;
}
use of net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem in project Osmand by osmandapp.
the class UpdateGpxCategoryTask method onPreExecute.
@Override
protected void onPreExecute() {
FragmentActivity activity = activityRef.get();
if (activity != null) {
progressDialog = new ProgressDialog(activity);
progressDialog.setTitle(EditTrackGroupDialogFragment.getCategoryName(app, group.getName()));
progressDialog.setMessage(newCategory != null ? "Changing name" : "Changing color");
progressDialog.setCancelable(false);
progressDialog.show();
GPXFile gpxFile = group.getGpx();
if (gpxFile != null) {
SavingTrackHelper savingTrackHelper = app.getSavingTrackHelper();
List<GpxDisplayItem> items = group.getModifiableList();
String prevCategory = group.getName();
boolean emptyCategory = TextUtils.isEmpty(prevCategory);
for (GpxDisplayItem item : items) {
WptPt wpt = item.locationStart;
if (wpt != null) {
boolean update = false;
if (emptyCategory) {
if (TextUtils.isEmpty(wpt.category)) {
update = true;
}
} else if (prevCategory.equals(wpt.category)) {
update = true;
}
if (update) {
wasUpdated = true;
String category = newCategory != null ? newCategory : wpt.category;
int color = newColor != null ? newColor : wpt.colourARGB;
if (gpxFile.showCurrentTrack) {
savingTrackHelper.updatePointData(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), wpt.desc, wpt.name, category, color);
} else {
gpxFile.updateWptPt(wpt, wpt.getLatitude(), wpt.getLongitude(), System.currentTimeMillis(), wpt.desc, wpt.name, category, color, wpt.getIconName(), wpt.getBackgroundType());
}
}
}
}
}
}
}
Aggregations