Skip to content

Commit

Permalink
Merge pull request #21865 from osmandapp/issue_21521
Browse files Browse the repository at this point in the history
Fix speed alarm
  • Loading branch information
Chumva authored Feb 6, 2025
2 parents 1419437 + 57c4b0c commit 84866af
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import net.osmand.plus.settings.backend.ApplicationMode;
import net.osmand.plus.settings.backend.OsmandSettings;
import net.osmand.plus.settings.enums.DrivingRegion;
import net.osmand.router.RouteSegmentResult;
import net.osmand.shared.settings.enums.SpeedConstants;
import net.osmand.plus.settings.enums.WidgetSize;
import net.osmand.plus.utils.AndroidUtils;
Expand Down Expand Up @@ -614,7 +615,13 @@ private AlarmInfo getSpeedLimitInfo() {
AlarmInfo alarm = waypointHelper.getSpeedLimitAlarm(speedFormat, whenExceeded);
if (alarm == null) {
Location loc = provider.getLastKnownLocation();
RouteDataObject dataObject = provider.getLastKnownRouteSegment();
RouteSegmentResult current = routingHelper.getRoute().getCurrentSegmentResult();
RouteDataObject dataObject = null;
if (current != null) {
dataObject = current.getObject();
} else {
dataObject = provider.getLastKnownRouteSegment();
}
if (dataObject != null && loc != null) {
alarm = waypointHelper.calculateSpeedLimitAlarm(dataObject, loc, speedFormat, whenExceeded);
}
Expand Down

0 comments on commit 84866af

Please sign in to comment.