diff --git a/OsmAnd/src/net/osmand/plus/GPXUtilities.java b/OsmAnd/src/net/osmand/plus/GPXUtilities.java index c30620b199..94774cd6f5 100644 --- a/OsmAnd/src/net/osmand/plus/GPXUtilities.java +++ b/OsmAnd/src/net/osmand/plus/GPXUtilities.java @@ -102,6 +102,21 @@ public class GPXUtilities { public float speed; } + public static class CreatedGpxWaypoint { + private WptPt point; + + public CreatedGpxWaypoint() { + } + + public WptPt getPoint() { + return point; + } + + public void setPoint(WptPt point) { + this.point = point; + } + } + public static class WptPt extends GPXExtensions implements LocationPoint { public boolean firstPoint = false; public boolean lastPoint = false; diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index 5fd14c9016..19a9674209 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -57,6 +57,7 @@ import net.osmand.plus.AppInitializer; import net.osmand.plus.AppInitializer.AppInitializeListener; import net.osmand.plus.AppInitializer.InitEvents; import net.osmand.plus.ApplicationMode; +import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarkerChangedListener; @@ -912,7 +913,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } else if (toShow instanceof QuadRect) { QuadRect qr = (QuadRect) toShow; mapView.fitRectToMap(qr.left, qr.right, qr.top, qr.bottom, (int) qr.width(), (int) qr.height(), 0); - } else { + } else if (toShow instanceof WptPt) { + WptPt createdGpxWaypoint = (WptPt) toShow; + } + else { mapContextMenu.show(latLonToShow, mapLabelToShow, toShow); } if (editToShow) { diff --git a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java index 29ac87ddc3..143234cb1b 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/TrackPointFragment.java @@ -36,7 +36,9 @@ import net.osmand.data.PointDescription; import net.osmand.plus.FavouritesDbHelper; import net.osmand.plus.GPXDatabase.GpxDataItem; import net.osmand.plus.GPXUtilities; +import net.osmand.plus.GPXUtilities.WptPt; import net.osmand.plus.GPXUtilities.GPXFile; +import net.osmand.plus.GPXUtilities.CreatedGpxWaypoint; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; @@ -91,11 +93,13 @@ public class TrackPointFragment extends OsmandExpandableListFragment { private ActionMode actionMode; private SearchView searchView; private FloatingActionButton fab; + private CreatedGpxWaypoint createdGpxWaypoint; @Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.app = getMyApplication(); + this.createdGpxWaypoint = new CreatedGpxWaypoint(); } @Override @@ -117,26 +121,16 @@ public class TrackPointFragment extends OsmandExpandableListFragment { fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - GpxDisplayItem item = null; - int groupCount = adapter.getGroupCount(); - for (int i = 0; i < groupCount; i++) { - GpxDisplayGroup group = adapter.getGroup(i); - if (group.getType() == GpxDisplayItemType.TRACK_POINTS) { - int childrenCount = adapter.getChildrenCount(i); - item = adapter.getChild(i, childrenCount - 1); - } - } - if (item != null) { - if (item.group.getGpx() != null) { - app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx()); - } - final OsmandSettings settings = app.getSettings(); - LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon); + final OsmandSettings settings = app.getSettings(); + GPXFile gpx = getGpx(); + WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null; + if (pointToShow != null) { + LatLon location = new LatLon(pointToShow.lat, pointToShow.lon); settings.setMapLocationToShow(location.getLatitude(), location.getLongitude(), settings.getLastKnownMapZoom(), - new PointDescription(PointDescription.POINT_TYPE_WPT, item.name), + new PointDescription(PointDescription.POINT_TYPE_WPT, getString(R.string.context_menu_item_add_waypoint)), false, - item.locationStart); + createdGpxWaypoint); MapActivity.launchMapActivityMoveToTop(getActivity()); }