Search in sources :

Example 1 with GpxDisplayItem

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));
}
Also used : TextViewEx(net.osmand.plus.widgets.TextViewEx) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager) LinearLayout(android.widget.LinearLayout)

Example 2 with GpxDisplayItem

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;
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) ArrayList(java.util.ArrayList) List(java.util.List)

Example 3 with GpxDisplayItem

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();
}
Also used : FavouritesHelper(net.osmand.plus.myplaces.FavouritesHelper) FavouritePoint(net.osmand.data.FavouritePoint) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) Fragment(androidx.fragment.app.Fragment)

Example 4 with GpxDisplayItem

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;
}
Also used : TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) WptPt(net.osmand.GPXUtilities.WptPt) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) TransportStopController(net.osmand.plus.mapcontextmenu.controllers.TransportStopController) FavouritePoint(net.osmand.data.FavouritePoint) MapMarker(net.osmand.plus.mapmarkers.MapMarker) MapillaryImage(net.osmand.plus.plugins.mapillary.MapillaryImage) AvoidSpecificRoads(net.osmand.plus.helpers.AvoidSpecificRoads) ParkingPositionMenuController(net.osmand.plus.plugins.parking.ParkingPositionMenuController) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) AidlMapPointWrapper(net.osmand.aidl.AidlMapPointWrapper) SelectedGpxPoint(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController.SelectedGpxPoint) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) TargetPoint(net.osmand.plus.helpers.TargetPointsHelper.TargetPoint) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) EditPOIMenuController(net.osmand.plus.plugins.osmedit.menu.EditPOIMenuController) TransportStopRoute(net.osmand.plus.transport.TransportStopRoute) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) TransportStop(net.osmand.data.TransportStop) Pair(android.util.Pair) Amenity(net.osmand.data.Amenity) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) AudioVideoNoteMenuController(net.osmand.plus.plugins.audionotes.AudioVideoNoteMenuController) OsmBugMenuController(net.osmand.plus.plugins.osmedit.menu.OsmBugMenuController) OsmPoint(net.osmand.plus.plugins.osmedit.data.OsmPoint) TransportRouteController(net.osmand.plus.mapcontextmenu.controllers.TransportRouteController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) DownloadMapObject(net.osmand.plus.views.layers.DownloadedRegionsLayer.DownloadMapObject) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) RenderedObjectMenuController(net.osmand.plus.mapcontextmenu.controllers.RenderedObjectMenuController) PointDescriptionMenuController(net.osmand.plus.mapcontextmenu.controllers.PointDescriptionMenuController) MapMarkerMenuController(net.osmand.plus.mapcontextmenu.controllers.MapMarkerMenuController) EditPOIMenuController(net.osmand.plus.plugins.osmedit.menu.EditPOIMenuController) AMapPointMenuController(net.osmand.plus.mapcontextmenu.controllers.AMapPointMenuController) WptPtMenuController(net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController) MapillaryMenuController(net.osmand.plus.plugins.mapillary.MapillaryMenuController) AudioVideoNoteMenuController(net.osmand.plus.plugins.audionotes.AudioVideoNoteMenuController) GpxItemMenuController(net.osmand.plus.mapcontextmenu.controllers.GpxItemMenuController) OsmBugMenuController(net.osmand.plus.plugins.osmedit.menu.OsmBugMenuController) HistoryMenuController(net.osmand.plus.mapcontextmenu.controllers.HistoryMenuController) MapDataMenuController(net.osmand.plus.mapcontextmenu.controllers.MapDataMenuController) ParkingPositionMenuController(net.osmand.plus.plugins.parking.ParkingPositionMenuController) TargetPointMenuController(net.osmand.plus.mapcontextmenu.controllers.TargetPointMenuController) AmenityMenuController(net.osmand.plus.mapcontextmenu.controllers.AmenityMenuController) SelectedGpxMenuController(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController) ImpassibleRoadsMenuController(net.osmand.plus.mapcontextmenu.controllers.ImpassibleRoadsMenuController) FavouritePointMenuController(net.osmand.plus.mapcontextmenu.controllers.FavouritePointMenuController) MyLocationMenuController(net.osmand.plus.mapcontextmenu.controllers.MyLocationMenuController) SelectedGpxMenuController(net.osmand.plus.mapcontextmenu.controllers.SelectedGpxMenuController) LatLon(net.osmand.data.LatLon) RenderedObject(net.osmand.NativeLibrary.RenderedObject) OpenStreetNote(net.osmand.plus.plugins.osmedit.OsmBugsLayer.OpenStreetNote) Recording(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin.Recording) MapillaryMenuController(net.osmand.plus.plugins.mapillary.MapillaryMenuController)

Example 5 with GpxDisplayItem

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());
                        }
                    }
                }
            }
        }
    }
}
Also used : FragmentActivity(androidx.fragment.app.FragmentActivity) WptPt(net.osmand.GPXUtilities.WptPt) GpxDisplayItem(net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem) SavingTrackHelper(net.osmand.plus.track.helpers.SavingTrackHelper) ProgressDialog(android.app.ProgressDialog) GPXFile(net.osmand.GPXUtilities.GPXFile)

Aggregations

GpxDisplayItem (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayItem)35 ArrayList (java.util.ArrayList)8 GPXFile (net.osmand.GPXUtilities.GPXFile)7 TrkSegment (net.osmand.GPXUtilities.TrkSegment)7 WptPt (net.osmand.GPXUtilities.WptPt)7 LatLon (net.osmand.data.LatLon)7 MapActivity (net.osmand.plus.activities.MapActivity)7 GpxDisplayGroup (net.osmand.plus.track.helpers.GpxSelectionHelper.GpxDisplayGroup)7 View (android.view.View)5 LineData (com.github.mikephil.charting.data.LineData)5 List (java.util.List)5 QuadRect (net.osmand.data.QuadRect)5 OrderedLineDataSet (net.osmand.plus.helpers.GpxUiHelper.OrderedLineDataSet)5 ILineDataSet (com.github.mikephil.charting.interfaces.datasets.ILineDataSet)4 OsmandApplication (net.osmand.plus.OsmandApplication)4 Matrix (android.graphics.Matrix)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 NonNull (androidx.annotation.NonNull)3 LinkedHashMap (java.util.LinkedHashMap)3