Merge pull request #7349 from osmandapp/BearingWidgetUpdates

Fix bearing widget update problem
This commit is contained in:
max-klaus 2019-07-30 14:06:20 +03:00 committed by GitHub
commit c89fda16f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -25,6 +25,7 @@ import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.StateChangedListener;
import net.osmand.binary.RouteDataObject; import net.osmand.binary.RouteDataObject;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -663,6 +664,17 @@ public class RouteInfoWidgetsFactory {
final TextInfoWidget bearingControl = new TextInfoWidget(map) { final TextInfoWidget bearingControl = new TextInfoWidget(map) {
private int cachedDegrees; private int cachedDegrees;
private float MIN_SPEED_FOR_HEADING = 1f; private float MIN_SPEED_FOR_HEADING = 1f;
private boolean angularUnitTypeChanged = false;
private StateChangedListener<OsmandSettings.AngularConstants> listener = new StateChangedListener<OsmandSettings.AngularConstants>() {
@Override
public void stateChanged(OsmandSettings.AngularConstants change) {
angularUnitTypeChanged = true;
}
};
{
getOsmandApplication().getSettings().ANGULAR_UNITS.addListener(listener);
}
private LatLon getNextTargetPoint() { private LatLon getNextTargetPoint() {
List<TargetPoint> points = getOsmandApplication().getTargetPointsHelper().getIntermediatePointsWithTarget(); List<TargetPoint> points = getOsmandApplication().getTargetPointsHelper().getIntermediatePointsWithTarget();
@ -675,7 +687,8 @@ public class RouteInfoWidgetsFactory {
boolean modeChanged = setIcons(relative ? relativeBearingResId : bearingResId, relative ? relativeBearingNightResId : bearingNightResId); boolean modeChanged = setIcons(relative ? relativeBearingResId : bearingResId, relative ? relativeBearingNightResId : bearingNightResId);
setContentTitle(relative ? R.string.map_widget_bearing : R.string.map_widget_magnetic_bearing); setContentTitle(relative ? R.string.map_widget_bearing : R.string.map_widget_magnetic_bearing);
int b = getBearing(relative); int b = getBearing(relative);
if (degreesChanged(cachedDegrees, b) || modeChanged) { if (angularUnitTypeChanged || degreesChanged(cachedDegrees, b) || modeChanged) {
angularUnitTypeChanged = false;
cachedDegrees = b; cachedDegrees = b;
if (b != -1000) { if (b != -1000) {
setText(OsmAndFormatter.getFormattedAzimuth(b, getOsmandApplication()) + (relative ? "" : " M"), null); setText(OsmAndFormatter.getFormattedAzimuth(b, getOsmandApplication()) + (relative ? "" : " M"), null);