Fix toShow
This commit is contained in:
parent
7027ce98fd
commit
3d60e37765
3 changed files with 31 additions and 18 deletions
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue