mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 14:53:59 +01:00 
			
		
		
		
	LocationPickerActivity.java: add null checks to showInMapApp
Before this change, there was no null checks when accessing data from an object, which could create null pointer exceptions at runtime. After this change, null checks are introduced to make sure null pointer exceptions will not occur.
This commit is contained in:
		
							parent
							
								
									efe6eb27ed
								
							
						
					
					
						commit
						caed893d23
					
				
					 1 changed files with 6 additions and 4 deletions
				
			
		|  | @ -400,19 +400,21 @@ 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(activity.equals("UploadActivity")){ | ||||
|         if(activity.equals("UploadActivity") && cameraPosition != null){ | ||||
|             position = new fr.free.nrw.commons.location.LatLng(cameraPosition.getLatitude(), | ||||
|                 cameraPosition.getLongitude(), 0.0f); | ||||
|         } else { | ||||
|         } else if(mapView != null){ | ||||
|             position = new fr.free.nrw.commons.location.LatLng(mapView.getMapCenter().getLatitude(), | ||||
|                 mapView.getMapCenter().getLongitude(), 0.0f); | ||||
|         } | ||||
| 
 | ||||
|         if(position != null){ | ||||
|             Utils.handleGeoCoordinates(this, position); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Moves the center of the map to the media's location (likely EXIF data), if that data | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Jason Whitmore
						Jason Whitmore