mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	LocationPickerActivity.java: create method to move location picker map to device GPS location
Before this method was created, several lines of code were required to move the location picker map to the device's GPS location. After this method was created, the location picker map can be moved to the GPS location in a single method call.
This commit is contained in:
		
							parent
							
								
									d941c2fa8e
								
							
						
					
					
						commit
						442ab08711
					
				
					 1 changed files with 16 additions and 1 deletions
				
			
		|  | @ -45,6 +45,7 @@ import fr.free.nrw.commons.coordinates.CoordinateEditHelper; | |||
| import fr.free.nrw.commons.filepicker.Constants; | ||||
| import fr.free.nrw.commons.kvstore.BasicKvStore; | ||||
| import fr.free.nrw.commons.kvstore.JsonKvStore; | ||||
| import fr.free.nrw.commons.location.LatLng; | ||||
| import fr.free.nrw.commons.location.LocationPermissionsHelper; | ||||
| import fr.free.nrw.commons.location.LocationPermissionsHelper.LocationPermissionCallback; | ||||
| import fr.free.nrw.commons.location.LocationServiceManager; | ||||
|  | @ -328,7 +329,6 @@ public class LocationPickerActivity extends BaseActivity implements | |||
| 
 | ||||
|     private void setupMapView() { | ||||
|         requestLocationPermissions(); | ||||
|         moveMapToMediaLocation(); | ||||
|         modifyLocationButton.setOnClickListener(v -> onClickModifyLocation()); | ||||
|         removeLocationButton.setOnClickListener(v -> onClickRemoveLocation()); | ||||
|         showInMapButton.setOnClickListener(v -> showInMapApp()); | ||||
|  | @ -417,6 +417,21 @@ public class LocationPickerActivity extends BaseActivity implements | |||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Moves the center of the map to the device's GPS location, if that data is available. | ||||
|      */ | ||||
|     private void moveMapToGPSLocation(){ | ||||
|         if(locationManager != null){ | ||||
|             fr.free.nrw.commons.location.LatLng location = locationManager.getLastLocation(); | ||||
| 
 | ||||
|             if(location != null){ | ||||
|                 GeoPoint point = new GeoPoint(location.getLatitude(), location.getLongitude()); | ||||
| 
 | ||||
|                 moveMapTo(point); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Select the preferable location | ||||
|      */ | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jason Whitmore
						Jason Whitmore