Skip to content

Commit 2282ce3

Browse files
5195: Fix upload wizard crash on tapping target icon (#5306)
* LocationPickerActivity: fix crash on setting location for pictures with no EXIF location * strings.xml: remove extra string introduced * optimise constants * LocationPickerActivity: request for permission only on tapping target icon * remove newline * handle location permissions using LocationPermissionsHelper * add null check to prevent crash
1 parent 70f8256 commit 2282ce3

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java

+10-7
Original file line numberDiff line numberDiff line change
@@ -483,13 +483,16 @@ public void onLocationPermissionDenied(String toastMessage) {
483483
@Override
484484
public void onLocationPermissionGranted() {
485485
fr.free.nrw.commons.location.LatLng currLocation = locationManager.getLastLocation();
486-
final CameraPosition position;
487-
position = new CameraPosition.Builder()
488-
.target(new com.mapbox.mapboxsdk.geometry.LatLng(currLocation.getLatitude(), currLocation.getLongitude(), 0)) // Sets the new camera position
489-
.zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level
490-
.build();
491-
492-
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000);
486+
if (currLocation != null) {
487+
final CameraPosition position;
488+
position = new CameraPosition.Builder()
489+
.target(new com.mapbox.mapboxsdk.geometry.LatLng(currLocation.getLatitude(),
490+
currLocation.getLongitude(), 0)) // Sets the new camera position
491+
.zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level
492+
.build();
493+
494+
mapboxMap.animateCamera(CameraUpdateFactory.newCameraPosition(position), 1000);
495+
}
493496
}
494497
});
495498
locationPermissionsHelper.handleLocationPermissions(locationAccessDialog, locationOffDialog);

0 commit comments

Comments
 (0)