From efe6eb27ed8f3079ddb3b6c4531dc25ce3876061 Mon Sep 17 00:00:00 2001 From: Jason Whitmore Date: Fri, 5 Jul 2024 17:41:26 -0700 Subject: [PATCH] LocationPickerActivity.java: refactor showInMapApp method Before this change, the showInMapApp method had correct behavior, but could be rewritten to become more clear. After this change, the showInMapApp code has been rewritten. Specifically, common code in an if statement has been factored out. --- .../LocationPicker/LocationPickerActivity.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java b/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java index 45c0c5b8d..80ca67c13 100644 --- a/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java +++ b/app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java @@ -400,16 +400,18 @@ public class LocationPickerActivity extends BaseActivity implements * If there is no EXIF data, the map will center on the commons app map center. */ private void showInMapApp() { + + fr.free.nrw.commons.location.LatLng position = null; //Check to see if EXIF location data is available - if(cameraPosition != null){ - Utils.handleGeoCoordinates(this, - new fr.free.nrw.commons.location.LatLng(cameraPosition.getLatitude(), - cameraPosition.getLongitude(), 0.0f)); + if(activity.equals("UploadActivity")){ + position = new fr.free.nrw.commons.location.LatLng(cameraPosition.getLatitude(), + cameraPosition.getLongitude(), 0.0f); } else { - Utils.handleGeoCoordinates(this, - new fr.free.nrw.commons.location.LatLng(mapView.getMapCenter().getLatitude(), - mapView.getMapCenter().getLongitude(), 0.0f)); + position = new fr.free.nrw.commons.location.LatLng(mapView.getMapCenter().getLatitude(), + mapView.getMapCenter().getLongitude(), 0.0f); } + + Utils.handleGeoCoordinates(this, position); } /**