Fix direction and distance indication
This commit is contained in:
parent
b112939f1e
commit
018c86c0fb
2 changed files with 26 additions and 10 deletions
|
@ -55,8 +55,10 @@
|
|||
android:id="@+id/marker_direction_icon"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginRight="4dp"
|
||||
android:layout_marginTop="1sp"
|
||||
tools:src="@drawable/ic_direction_arrow"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
|
@ -68,6 +70,7 @@
|
|||
tools:text="213 m"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/marker_divider_point"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text=" • "
|
||||
|
|
|
@ -27,7 +27,6 @@ import net.osmand.plus.OsmAndLocationProvider.OsmAndLocationListener;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.dashboard.DashLocationFragment;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.views.OsmandMapTileView;
|
||||
|
@ -57,6 +56,7 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi
|
|||
|
||||
private ImageView arrowIv;
|
||||
private TextView distanceTv;
|
||||
private View dividerPoint;
|
||||
|
||||
public void setMarker(MapMarker marker) {
|
||||
this.marker = marker;
|
||||
|
@ -88,6 +88,7 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi
|
|||
|
||||
arrowIv = (ImageView) mainView.findViewById(R.id.marker_direction_icon);
|
||||
distanceTv = (TextView) mainView.findViewById(R.id.marker_distance);
|
||||
dividerPoint = mainView.findViewById(R.id.marker_divider_point);
|
||||
|
||||
String descr;
|
||||
if ((descr = marker.groupName) != null) {
|
||||
|
@ -251,20 +252,32 @@ public class MarkerMenuOnMapFragment extends Fragment implements OsmAndCompassLi
|
|||
if (location == null) {
|
||||
location = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
}
|
||||
MapViewTrackingUtilities utilities = mapActivity.getMapViewTrackingUtilities();
|
||||
|
||||
boolean useCenter = !(utilities.isMapLinkedToLocation() && location != null);
|
||||
LatLon loc = useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude());
|
||||
float head = useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99;
|
||||
|
||||
DashLocationFragment.updateLocationView(useCenter, loc, head, arrowIv,
|
||||
R.drawable.ic_direction_arrow, 0, distanceTv, marker.point,
|
||||
DashLocationFragment.getScreenOrientation(mapActivity), mapActivity.getMyApplication(), mapActivity, true);
|
||||
if (location != null) {
|
||||
mark(View.VISIBLE, arrowIv, distanceTv, dividerPoint);
|
||||
DashLocationFragment.updateLocationView(false,
|
||||
new LatLon(location.getLatitude(), location.getLongitude()),
|
||||
heading != null ? heading : 0f,
|
||||
arrowIv,
|
||||
distanceTv,
|
||||
marker.getLatitude(),
|
||||
marker.getLongitude(),
|
||||
DashLocationFragment.getScreenOrientation(mapActivity),
|
||||
mapActivity.getMyApplication(),
|
||||
mapActivity);
|
||||
} else {
|
||||
mark(View.GONE, arrowIv, distanceTv, dividerPoint);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void mark(int visibility, View... views) {
|
||||
for (View v : views) {
|
||||
v.setVisibility(visibility);
|
||||
}
|
||||
}
|
||||
|
||||
private void enterMenuMode() {
|
||||
final MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
|
|
Loading…
Reference in a new issue