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.
This commit is contained in:
Jason Whitmore 2024-07-05 17:41:26 -07:00
parent 97fa77deb8
commit efe6eb27ed

View file

@ -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. * If there is no EXIF data, the map will center on the commons app map center.
*/ */
private void showInMapApp() { private void showInMapApp() {
fr.free.nrw.commons.location.LatLng position = null;
//Check to see if EXIF location data is available //Check to see if EXIF location data is available
if(cameraPosition != null){ if(activity.equals("UploadActivity")){
Utils.handleGeoCoordinates(this, position = new fr.free.nrw.commons.location.LatLng(cameraPosition.getLatitude(),
new fr.free.nrw.commons.location.LatLng(cameraPosition.getLatitude(), cameraPosition.getLongitude(), 0.0f);
cameraPosition.getLongitude(), 0.0f));
} else { } else {
Utils.handleGeoCoordinates(this, position = new fr.free.nrw.commons.location.LatLng(mapView.getMapCenter().getLatitude(),
new fr.free.nrw.commons.location.LatLng(mapView.getMapCenter().getLatitude(), mapView.getMapCenter().getLongitude(), 0.0f);
mapView.getMapCenter().getLongitude(), 0.0f));
} }
Utils.handleGeoCoordinates(this, position);
} }
/** /**