Fix potential exceptions
This commit is contained in:
parent
11246e3d3d
commit
6631b5744f
5 changed files with 11 additions and 10 deletions
|
@ -499,8 +499,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
}
|
||||
|
||||
private float calcGeoMagneticCorrection(float val) {
|
||||
if (previousCorrectionValue == 360 && getLastKnownLocation() != null) {
|
||||
net.osmand.Location l = getLastKnownLocation();
|
||||
net.osmand.Location l = getLastKnownLocation();
|
||||
if (previousCorrectionValue == 360 && l != null) {
|
||||
GeomagneticField gf = new GeomagneticField((float) l.getLatitude(), (float) l.getLongitude(), (float) l.getAltitude(),
|
||||
System.currentTimeMillis());
|
||||
previousCorrectionValue = gf.getDeclination();
|
||||
|
|
|
@ -980,8 +980,7 @@ public class MapContextMenuFragment extends Fragment implements DownloadEvents {
|
|||
if (app != null && view != null) {
|
||||
View compassView = view.findViewById(R.id.compass_layout);
|
||||
Location ll = app.getLocationProvider().getLastKnownLocation();
|
||||
boolean gpsFixed = ll != null && System.currentTimeMillis() - ll.getTime() < 1000 * 60 * 60 * 20;
|
||||
if (gpsFixed && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) {
|
||||
if (ll != null && menu.displayDistanceDirection() && menu.getCurrentMenuState() != MenuState.FULL_SCREEN) {
|
||||
updateDistanceDirection();
|
||||
compassView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
|
|
|
@ -27,6 +27,7 @@ import android.widget.SeekBar;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.core.android.MapRendererContext;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -794,8 +795,8 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
|
||||
private void updateMyLocation(RoutingHelper rh, boolean dialogOpened) {
|
||||
boolean enabled = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation() != null &&
|
||||
!isLocationOutdated(mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation());
|
||||
Location lastKnownLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
boolean enabled = lastKnownLocation != null && !isLocationOutdated(lastKnownLocation);
|
||||
boolean tracked = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
|
||||
if (!enabled) {
|
||||
|
|
|
@ -86,9 +86,9 @@ public class PointLocationLayer extends OsmandMapLayer implements ContextMenuLay
|
|||
}
|
||||
// draw
|
||||
boolean nm = nightMode != null && nightMode.isNightMode();
|
||||
updateIcons(view.getSettings().getApplicationMode(), nm,
|
||||
isLocationOutdated(locationProvider.getLastKnownLocation()));
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
updateIcons(view.getSettings().getApplicationMode(), nm,
|
||||
isLocationOutdated(lastKnownLocation));
|
||||
if(lastKnownLocation == null || view == null){
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -718,10 +718,11 @@ public class MapInfoWidgetsFactory {
|
|||
settings.SHOW_STREET_NAME.get()) {
|
||||
RouteDataObject rt = locationProvider.getLastKnownRouteSegment();
|
||||
if (rt != null) {
|
||||
Location lastKnownLocation = locationProvider.getLastKnownLocation();
|
||||
text = RoutingHelper.formatStreetName(
|
||||
rt.getName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get()),
|
||||
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())),
|
||||
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(locationProvider.getLastKnownLocation())),
|
||||
rt.getRef(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
rt.getDestinationName(settings.MAP_PREFERRED_LOCALE.get(), settings.MAP_TRANSLITERATE_NAMES.get(), rt.bearingVsRouteDirection(lastKnownLocation)),
|
||||
"»");
|
||||
}
|
||||
if (text == null) {
|
||||
|
|
Loading…
Reference in a new issue