Small issues

This commit is contained in:
Victor Shcherb 2018-05-24 10:11:37 +02:00
parent ef15bf722f
commit f6859d5ed0
2 changed files with 16 additions and 27 deletions

View file

@ -137,7 +137,7 @@ public class UiUtilities {
} else { } else {
useCenter = true; useCenter = true;
fromLoc = app.getMapViewTrackingUtilities().getMapLocation(); fromLoc = app.getMapViewTrackingUtilities().getMapLocation();
h = app.getMapViewTrackingUtilities().getHeading(); h = app.getMapViewTrackingUtilities().getMapRotate();
if(h != null) { if(h != null) {
h = -h; h = -h;
} }
@ -172,7 +172,7 @@ public class UiUtilities {
if (fromLoc == null || h == null || toLoc == null) { if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0); dd.setAngle(0);
} else { } else {
float orientation = (cache == null ? 0 : cache.screenOrientation) * 90; float orientation = (cache == null ? 0 : -cache.screenOrientation) * 90;
dd.setAngle(mes[1] - h + 180 + orientation); dd.setAngle(mes[1] - h + 180 + orientation);
} }
if (newImage) { if (newImage) {

View file

@ -1,15 +1,8 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import android.app.Dialog; import java.lang.ref.WeakReference;
import android.app.ProgressDialog; import java.util.LinkedList;
import android.content.DialogInterface; import java.util.List;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.LinearLayout;
import net.osmand.CallbackWithObject; import net.osmand.CallbackWithObject;
import net.osmand.Location; import net.osmand.Location;
@ -56,11 +49,16 @@ import net.osmand.plus.views.OsmandMapLayer;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarController;
import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType; import net.osmand.plus.views.mapwidgets.MapInfoWidgetsFactory.TopToolbarControllerType;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.MapUtils; import android.app.Dialog;
import android.app.ProgressDialog;
import java.lang.ref.WeakReference; import android.content.DialogInterface;
import java.util.LinkedList; import android.graphics.drawable.Drawable;
import java.util.List; import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.widget.LinearLayout;
public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode>, public class MapContextMenu extends MenuTitleController implements StateChangedListener<ApplicationMode>,
MapMarkerChangedListener, TargetPointChangedListener { MapMarkerChangedListener, TargetPointChangedListener {
@ -84,9 +82,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
private boolean centerMarker; private boolean centerMarker;
private int mapZoom; private int mapZoom;
private LatLon myLocation;
private boolean inLocationUpdate = false; private boolean inLocationUpdate = false;
private boolean cachedMyLocation;
private boolean appModeChanged; private boolean appModeChanged;
private boolean appModeListenerAdded; private boolean appModeListenerAdded;
private boolean autoHide; private boolean autoHide;
@ -293,9 +289,6 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
boolean update, boolean restorePrevious) { boolean update, boolean restorePrevious) {
OsmandApplication app = mapActivity.getMyApplication(); OsmandApplication app = mapActivity.getMyApplication();
if (myLocation == null) {
updateMyLocation(app.getLocationProvider().getLastKnownLocation(), false);
}
if (!update && isVisible()) { if (!update && isVisible()) {
if (this.object == null || !this.object.equals(object)) { if (this.object == null || !this.object.equals(object)) {
@ -422,7 +415,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
} }
public void onFragmentResume() { public void onFragmentResume() {
if (active && displayDistanceDirection() && myLocation != null) { if (active && displayDistanceDirection()) {
updateLocation(false, true, false); updateLocation(false, true, false);
} }
} }
@ -1252,12 +1245,8 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
private void updateMyLocation(Location location, boolean updateLocationUi) { private void updateMyLocation(Location location, boolean updateLocationUi) {
if (location == null) { if (location == null) {
location = getMapActivity().getMyApplication().getLocationProvider().getLastStaleKnownLocation(); location = getMapActivity().getMyApplication().getLocationProvider().getLastStaleKnownLocation();
cachedMyLocation = location != null;
} else {
cachedMyLocation = false;
} }
if (location != null) { if (location != null) {
myLocation = new LatLon(location.getLatitude(), location.getLongitude());
if (updateLocationUi) { if (updateLocationUi) {
updateLocation(false, true, false); updateLocation(false, true, false);
} }