Fix markers selection deadloop

This commit is contained in:
Alexey Kulish 2016-02-23 12:43:00 +03:00
parent 5b75d213ae
commit a96b2b5040
2 changed files with 14 additions and 10 deletions

View file

@ -649,9 +649,11 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
mapActivity.getString(R.string.shared_string_address) + mapActivity.getString(R.string.shared_string_ellipsis)));
TargetPoint start = getTargets().getPointToStart();
int startPos = -1;
if (start != null) {
String oname = start.getOnlyName().length() > 0 ? start.getOnlyName()
: (mapActivity.getString(R.string.route_descr_map_location) + " " + getRoutePointDescription(start.getLatitude(), start.getLongitude()));
startPos = fromActions.size();
fromActions.add(new RouteSpinnerRow(SPINNER_START_ID, R.drawable.ic_action_get_my_location, oname));
final LatLon latLon = start.point;
@ -677,7 +679,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
fromAdapter.addAll(fromActions);
fromSpinner.setAdapter(fromAdapter);
if (start != null) {
fromSpinner.setSelection(fromActions.size() - 1);
fromSpinner.setSelection(startPos);
} else {
if (mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() == null) {
fromSpinner.setPromptId(R.string.search_poi_location);

View file

@ -58,15 +58,17 @@ public class MapMarkerSelectionFragment extends BaseOsmAndDialogFragment {
screenOrientation = DashLocationFragment.getScreenOrientation(mapActivity);
MapViewTrackingUtilities trackingUtils = mapActivity.getMapViewTrackingUtilities();
float head = trackingUtils.getHeading();
float mapRotation = mapActivity.getMapRotate();
LatLon mw = mapActivity.getMapLocation();
Location l = trackingUtils.getMyLocation();
boolean mapLinked = trackingUtils.isMapLinkedToLocation() && l != null;
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
useCenter = !mapLinked;
loc = (useCenter ? mw : myLoc);
heading = useCenter ? -mapRotation : head;
if (trackingUtils != null) {
float head = trackingUtils.getHeading();
float mapRotation = mapActivity.getMapRotate();
LatLon mw = mapActivity.getMapLocation();
Location l = trackingUtils.getMyLocation();
boolean mapLinked = trackingUtils.isMapLinkedToLocation() && l != null;
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
useCenter = !mapLinked;
loc = (useCenter ? mw : myLoc);
heading = useCenter ? -mapRotation : head;
}
}
nightMode = !app.getSettings().isLightContent();