mirror of
				https://github.com/commons-app/apps-android-commons.git
				synced 2025-10-31 06:43:56 +01:00 
			
		
		
		
	Refactor curlatLng to currentLatLng (#5646)
Co-authored-by: Aahlad <aahladkethineeedi@gmail.com>
This commit is contained in:
		
							parent
							
								
									cd337b000e
								
							
						
					
					
						commit
						a45ab9cf16
					
				
					 14 changed files with 102 additions and 102 deletions
				
			
		|  | @ -12,7 +12,7 @@ public abstract class MapController { | |||
|     public class NearbyPlacesInfo { | ||||
|         public List<Place> placeList; // List of nearby places | ||||
|         public LatLng[] boundaryCoordinates; // Corners of nearby area | ||||
|         public LatLng curLatLng; // Current location when this places are populated | ||||
|         public LatLng currentLatLng; // Current location when this places are populated | ||||
|         public LatLng searchLatLng; // Search location for finding this places | ||||
|         public List<Media> mediaList; // Search location for finding this places | ||||
|     } | ||||
|  | @ -23,7 +23,7 @@ public abstract class MapController { | |||
|     public class ExplorePlacesInfo { | ||||
|         public List<Place> explorePlaceList; // List of nearby places | ||||
|         public LatLng[] boundaryCoordinates; // Corners of nearby area | ||||
|         public LatLng curLatLng; // Current location when this places are populated | ||||
|         public LatLng currentLatLng; // Current location when this places are populated | ||||
|         public LatLng searchLatLng; // Search location for finding this places | ||||
|         public List<Media> mediaList; // Search location for finding this places | ||||
|     } | ||||
|  |  | |||
|  | @ -121,7 +121,7 @@ public class ContributionsFragment | |||
|     @Inject | ||||
|     SessionManager sessionManager; | ||||
| 
 | ||||
|     private LatLng curLatLng; | ||||
|     private LatLng currentLatLng; | ||||
| 
 | ||||
|     private boolean isFragmentAttachedBefore = false; | ||||
|     private View checkBoxView; | ||||
|  | @ -542,9 +542,9 @@ public class ContributionsFragment | |||
| 
 | ||||
| 
 | ||||
|     private void updateClosestNearbyCardViewInfo() { | ||||
|         curLatLng = locationManager.getLastLocation(); | ||||
|         currentLatLng = locationManager.getLastLocation(); | ||||
|         compositeDisposable.add(Observable.fromCallable(() -> nearbyController | ||||
|                 .loadAttractionsFromLocation(curLatLng, curLatLng, true, | ||||
|                 .loadAttractionsFromLocation(currentLatLng, currentLatLng, true, | ||||
|                     false)) // thanks to boolean, it will only return closest result | ||||
|             .subscribeOn(Schedulers.io()) | ||||
|             .observeOn(AndroidSchedulers.mainThread()) | ||||
|  | @ -571,9 +571,9 @@ public class ContributionsFragment | |||
|             if (closestNearbyPlace == null) { | ||||
|                 binding.cardViewNearby.setVisibility(View.GONE); | ||||
|             } else { | ||||
|                 String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.location); | ||||
|                 String distance = formatDistanceBetween(currentLatLng, closestNearbyPlace.location); | ||||
|                 closestNearbyPlace.setDistance(distance); | ||||
|                 direction = (float) computeBearing(curLatLng, closestNearbyPlace.location); | ||||
|                 direction = (float) computeBearing(currentLatLng, closestNearbyPlace.location); | ||||
|                 binding.cardViewNearby.updateContent(closestNearbyPlace); | ||||
|             } | ||||
|         } else { | ||||
|  |  | |||
|  | @ -20,11 +20,11 @@ public class ExploreMapCalls { | |||
|     /** | ||||
|      * Calls method to query Commons for uploads around a location | ||||
|      * | ||||
|      * @param curLatLng coordinates of search location | ||||
|      * @param currentLatLng coordinates of search location | ||||
|      * @return list of places obtained | ||||
|      */ | ||||
|     List<Media> callCommonsQuery(final LatLng curLatLng) { | ||||
|         String coordinates = curLatLng.getLatitude() + "|" + curLatLng.getLongitude(); | ||||
|     List<Media> callCommonsQuery(final LatLng currentLatLng) { | ||||
|         String coordinates = currentLatLng.getLatitude() + "|" + currentLatLng.getLongitude(); | ||||
|         return mediaClient.getMediaListFromGeoSearch(coordinates).blockingGet(); | ||||
|     } | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,9 +11,9 @@ public class ExploreMapContract { | |||
| 
 | ||||
|     interface View { | ||||
|         boolean isNetworkConnectionEstablished(); | ||||
|         void populatePlaces(LatLng curlatLng); | ||||
|         void populatePlaces(LatLng currentLatLng); | ||||
|         void checkPermissionsAndPerformAction(); | ||||
|         void recenterMap(LatLng curLatLng); | ||||
|         void recenterMap(LatLng currentLatLng); | ||||
|         void showLocationOffDialog(); | ||||
|         void openLocationSettings(); | ||||
|         void hideBottomDetailsSheet(); | ||||
|  |  | |||
|  | @ -45,17 +45,17 @@ public class ExploreMapController extends MapController { | |||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Takes location as parameter and returns ExplorePlaces info that holds curLatLng, mediaList, | ||||
|      * Takes location as parameter and returns ExplorePlaces info that holds currentLatLng, mediaList, | ||||
|      * explorePlaceList and boundaryCoordinates | ||||
|      * | ||||
|      * @param curLatLng                     is current geolocation | ||||
|      * @param currentLatLng                     is current geolocation | ||||
|      * @param searchLatLng                  is the location that we want to search around | ||||
|      * @param checkingAroundCurrentLocation is a boolean flag. True if we want to check around | ||||
|      *                                      current location, false if another location | ||||
|      * @return explorePlacesInfo info that holds curLatLng, mediaList, explorePlaceList and | ||||
|      * @return explorePlacesInfo info that holds currentLatLng, mediaList, explorePlaceList and | ||||
|      * boundaryCoordinates | ||||
|      */ | ||||
|     public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng searchLatLng, | ||||
|     public ExplorePlacesInfo loadAttractionsFromLocation(LatLng currentLatLng, LatLng searchLatLng, | ||||
|         boolean checkingAroundCurrentLocation) { | ||||
| 
 | ||||
|         if (searchLatLng == null) { | ||||
|  | @ -65,7 +65,7 @@ public class ExploreMapController extends MapController { | |||
| 
 | ||||
|         ExplorePlacesInfo explorePlacesInfo = new ExplorePlacesInfo(); | ||||
|         try { | ||||
|             explorePlacesInfo.curLatLng = curLatLng; | ||||
|             explorePlacesInfo.currentLatLng = currentLatLng; | ||||
|             latestSearchLocation = searchLatLng; | ||||
| 
 | ||||
|             List<Media> mediaList = exploreMapCalls.callCommonsQuery(searchLatLng); | ||||
|  | @ -115,7 +115,7 @@ public class ExploreMapController extends MapController { | |||
|             // Our radius searched around us, will be used to understand when user search their own location, we will follow them | ||||
|             if (checkingAroundCurrentLocation) { | ||||
|                 currentLocationSearchRadius = latestSearchRadius; | ||||
|                 currentLocation = curLatLng; | ||||
|                 currentLocation = currentLatLng; | ||||
|             } | ||||
|         } catch (Exception e) { | ||||
|             e.printStackTrace(); | ||||
|  | @ -129,7 +129,7 @@ public class ExploreMapController extends MapController { | |||
|      * @return baseMarkerOptions list that holds nearby places with their icons | ||||
|      */ | ||||
|     public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions( | ||||
|         LatLng curLatLng, | ||||
|         LatLng currentLatLng, | ||||
|         final List<Place> placeList, | ||||
|         Context context, | ||||
|         NearbyBaseMarkerThumbCallback callback, | ||||
|  | @ -151,7 +151,7 @@ public class ExploreMapController extends MapController { | |||
|         if (vectorDrawable != null) { | ||||
|             for (Place explorePlace : placeList) { | ||||
|                 final BaseMarker baseMarker = new BaseMarker(); | ||||
|                 String distance = formatDistanceBetween(curLatLng, explorePlace.location); | ||||
|                 String distance = formatDistanceBetween(currentLatLng, explorePlace.location); | ||||
|                 explorePlace.setDistance(distance); | ||||
| 
 | ||||
|                 baseMarker.setTitle( | ||||
|  |  | |||
|  | @ -391,18 +391,18 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void populatePlaces(LatLng curLatLng) { | ||||
|     public void populatePlaces(LatLng currentLatLng) { | ||||
|         final Observable<MapController.ExplorePlacesInfo> nearbyPlacesInfoObservable; | ||||
|         if (curLatLng == null) { | ||||
|         if (currentLatLng == null) { | ||||
|             checkPermissionsAndPerformAction(); | ||||
|             return; | ||||
|         } | ||||
|         if (curLatLng.equals(getLastMapFocus())) { // Means we are checking around current location | ||||
|             nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(curLatLng, | ||||
|         if (currentLatLng.equals(getLastMapFocus())) { // Means we are checking around current location | ||||
|             nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(currentLatLng, | ||||
|                 getLastMapFocus(), true); | ||||
|         } else { | ||||
|             nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(getLastMapFocus(), | ||||
|                 curLatLng, false); | ||||
|                 currentLatLng, false); | ||||
|         } | ||||
|         compositeDisposable.add(nearbyPlacesInfoObservable | ||||
|             .subscribeOn(Schedulers.io()) | ||||
|  | @ -413,7 +413,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment | |||
|                         showResponseMessage(getString(R.string.no_pictures_in_this_area)); | ||||
|                     } | ||||
|                     updateMapMarkers(explorePlacesInfo); | ||||
|                     lastMapFocus = new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()); | ||||
|                     lastMapFocus = new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude()); | ||||
|                 }, | ||||
|                 throwable -> { | ||||
|                     Timber.d(throwable); | ||||
|  | @ -479,8 +479,8 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void recenterMap(LatLng curLatLng) { | ||||
|         if (isPermissionDenied || curLatLng == null) { | ||||
|     public void recenterMap(LatLng currentLatLng) { | ||||
|         if (isPermissionDenied || currentLatLng == null) { | ||||
|             recenterToUserLocation = true; | ||||
|             checkPermissionsAndPerformAction(); | ||||
|             if (!isPermissionDenied && !(locationManager.isNetworkProviderEnabled() | ||||
|  | @ -489,9 +489,9 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment | |||
|             } | ||||
|             return; | ||||
|         } | ||||
|         recenterMarkerToPosition(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); | ||||
|         recenterMarkerToPosition(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude())); | ||||
|         binding.mapView.getController() | ||||
|             .animateTo(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); | ||||
|             .animateTo(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude())); | ||||
|         if (lastMapFocus != null) { | ||||
|             Location mylocation = new Location(""); | ||||
|             Location dest_location = new Location(""); | ||||
|  |  | |||
|  | @ -25,7 +25,7 @@ public class ExploreMapPresenter | |||
| 
 | ||||
|     BookmarkLocationsDao bookmarkLocationDao; | ||||
|     private boolean isNearbyLocked; | ||||
|     private LatLng curLatLng; | ||||
|     private LatLng currentLatLng; | ||||
|     private ExploreMapController exploreMapController; | ||||
| 
 | ||||
|     private static final ExploreMapContract.View DUMMY = (ExploreMapContract.View) Proxy | ||||
|  | @ -119,7 +119,7 @@ public class ExploreMapPresenter | |||
|     @Override | ||||
|     public void setActionListeners(JsonKvStore applicationKvStore) { | ||||
|         exploreMapFragmentView.setFABRecenterAction(v -> { | ||||
|             exploreMapFragmentView.recenterMap(curLatLng); | ||||
|             exploreMapFragmentView.recenterMap(currentLatLng); | ||||
|         }); | ||||
| 
 | ||||
|     } | ||||
|  | @ -144,11 +144,11 @@ public class ExploreMapPresenter | |||
|         exploreMapFragmentView.addSearchThisAreaButtonAction(); | ||||
|     } | ||||
| 
 | ||||
|     public Observable<ExplorePlacesInfo> loadAttractionsFromLocation(LatLng curLatLng, | ||||
|     public Observable<ExplorePlacesInfo> loadAttractionsFromLocation(LatLng currentLatLng, | ||||
|         LatLng searchLatLng, boolean checkingAroundCurrent) { | ||||
|         return Observable | ||||
|             .fromCallable(() -> exploreMapController | ||||
|                 .loadAttractionsFromLocation(curLatLng, searchLatLng, checkingAroundCurrent)); | ||||
|                 .loadAttractionsFromLocation(currentLatLng, searchLatLng, checkingAroundCurrent)); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  | @ -169,7 +169,7 @@ public class ExploreMapPresenter | |||
| 
 | ||||
|     void prepareNearbyBaseMarkers(MapController.ExplorePlacesInfo explorePlacesInfo) { | ||||
|         exploreMapController | ||||
|             .loadAttractionsFromLocationToBaseMarkerOptions(explorePlacesInfo.curLatLng, | ||||
|             .loadAttractionsFromLocationToBaseMarkerOptions(explorePlacesInfo.currentLatLng, | ||||
|                 // Curlatlang will be used to calculate distances | ||||
|                 explorePlacesInfo.explorePlaceList, | ||||
|                 exploreMapFragmentView.getContext(), | ||||
|  |  | |||
|  | @ -39,14 +39,14 @@ public class NearbyController extends MapController { | |||
|     /** | ||||
|      * Prepares Place list to make their distance information update later. | ||||
|      * | ||||
|      * @param curLatLng           current location for user | ||||
|      * @param currentLatLng           current location for user | ||||
|      * @param searchLatLng        the location user wants to search around | ||||
|      * @param returnClosestResult if this search is done to find closest result or all results | ||||
|      * @param customQuery         if this search is done via an advanced query | ||||
|      * @return NearbyPlacesInfo a variable holds Place list without distance information and | ||||
|      * boundary coordinates of current Place List | ||||
|      */ | ||||
|     public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng curLatLng, | ||||
|     public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng currentLatLng, | ||||
|         final LatLng searchLatLng, | ||||
|         final boolean returnClosestResult, final boolean checkingAroundCurrentLocation, | ||||
|         @Nullable final String customQuery) throws Exception { | ||||
|  | @ -54,7 +54,7 @@ public class NearbyController extends MapController { | |||
|         Timber.d("Loading attractions near %s", searchLatLng); | ||||
|         NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo(); | ||||
|         if (searchLatLng == null) { | ||||
|             Timber.d("Loading attractions nearby, but curLatLng is null"); | ||||
|             Timber.d("Loading attractions nearby, but currentLatLng is null"); | ||||
|             return null; | ||||
|         } | ||||
|         List<Place> places = nearbyPlaces | ||||
|  | @ -68,11 +68,11 @@ public class NearbyController extends MapController { | |||
|                 places.get(0).location, // west | ||||
|                 places.get(0).location};// east, init with a random location | ||||
| 
 | ||||
|             if (curLatLng != null) { | ||||
|             if (currentLatLng != null) { | ||||
|                 Timber.d("Sorting places by distance..."); | ||||
|                 final Map<Place, Double> distances = new HashMap<>(); | ||||
|                 for (Place place : places) { | ||||
|                     distances.put(place, computeDistanceBetween(place.location, curLatLng)); | ||||
|                     distances.put(place, computeDistanceBetween(place.location, currentLatLng)); | ||||
|                     // Find boundaries with basic find max approach | ||||
|                     if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) { | ||||
|                         boundaryCoordinates[0] = place.location; | ||||
|  | @ -95,7 +95,7 @@ public class NearbyController extends MapController { | |||
|                     } | ||||
|                 ); | ||||
|             } | ||||
|             nearbyPlacesInfo.curLatLng = curLatLng; | ||||
|             nearbyPlacesInfo.currentLatLng = currentLatLng; | ||||
|             nearbyPlacesInfo.searchLatLng = searchLatLng; | ||||
|             nearbyPlacesInfo.placeList = places; | ||||
|             nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates; | ||||
|  | @ -109,7 +109,7 @@ public class NearbyController extends MapController { | |||
|                 // Our radius searched around us, will be used to understand when user search their own location, we will follow them | ||||
|                 if (checkingAroundCurrentLocation) { | ||||
|                     currentLocationSearchRadius = nearbyPlaces.radius * 1000; // to meter | ||||
|                     currentLocation = curLatLng; | ||||
|                     currentLocation = currentLatLng; | ||||
|                 } | ||||
|             } | ||||
| 
 | ||||
|  | @ -121,7 +121,7 @@ public class NearbyController extends MapController { | |||
|     /** | ||||
|      * Prepares Place list to make their distance information update later. | ||||
|      * | ||||
|      * @param curLatLng                     The current latitude and longitude. | ||||
|      * @param currentLatLng                     The current latitude and longitude. | ||||
|      * @param screenTopRight                The top right corner of the screen (latitude, | ||||
|      *                                      longitude). | ||||
|      * @param screenBottomLeft              The bottom left corner of the screen (latitude, | ||||
|  | @ -137,7 +137,7 @@ public class NearbyController extends MapController { | |||
|      * @return An object containing information about nearby places. | ||||
|      * @throws Exception If an error occurs during the retrieval process. | ||||
|      */ | ||||
|     public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng curLatLng, | ||||
|     public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng currentLatLng, | ||||
|         final fr.free.nrw.commons.location.LatLng screenTopRight, | ||||
|         final fr.free.nrw.commons.location.LatLng screenBottomLeft, final LatLng searchLatLng, | ||||
|         final boolean returnClosestResult, final boolean checkingAroundCurrentLocation, | ||||
|  | @ -148,7 +148,7 @@ public class NearbyController extends MapController { | |||
|         NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo(); | ||||
| 
 | ||||
|         if (searchLatLng == null) { | ||||
|             Timber.d("Loading attractions nearby, but curLatLng is null"); | ||||
|             Timber.d("Loading attractions nearby, but currentLatLng is null"); | ||||
|             return null; | ||||
|         } | ||||
| 
 | ||||
|  | @ -162,11 +162,11 @@ public class NearbyController extends MapController { | |||
|                 places.get(0).location, // west | ||||
|                 places.get(0).location};// east, init with a random location | ||||
| 
 | ||||
|             if (curLatLng != null) { | ||||
|             if (currentLatLng != null) { | ||||
|                 Timber.d("Sorting places by distance..."); | ||||
|                 final Map<Place, Double> distances = new HashMap<>(); | ||||
|                 for (Place place : places) { | ||||
|                     distances.put(place, computeDistanceBetween(place.location, curLatLng)); | ||||
|                     distances.put(place, computeDistanceBetween(place.location, currentLatLng)); | ||||
|                     // Find boundaries with basic find max approach | ||||
|                     if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) { | ||||
|                         boundaryCoordinates[0] = place.location; | ||||
|  | @ -189,7 +189,7 @@ public class NearbyController extends MapController { | |||
|                     } | ||||
|                 ); | ||||
|             } | ||||
|             nearbyPlacesInfo.curLatLng = curLatLng; | ||||
|             nearbyPlacesInfo.currentLatLng = currentLatLng; | ||||
|             nearbyPlacesInfo.searchLatLng = searchLatLng; | ||||
|             nearbyPlacesInfo.placeList = places; | ||||
|             nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates; | ||||
|  | @ -203,7 +203,7 @@ public class NearbyController extends MapController { | |||
|                 // Our radius searched around us, will be used to understand when user search their own location, we will follow them | ||||
|                 if (checkingAroundCurrentLocation) { | ||||
|                     currentLocationSearchRadius = nearbyPlaces.radius * 1000; // to meter | ||||
|                     currentLocation = curLatLng; | ||||
|                     currentLocation = currentLatLng; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | @ -213,29 +213,29 @@ public class NearbyController extends MapController { | |||
|     /** | ||||
|      * Prepares Place list to make their distance information update later. | ||||
|      * | ||||
|      * @param curLatLng           current location for user | ||||
|      * @param currentLatLng           current location for user | ||||
|      * @param searchLatLng        the location user wants to search around | ||||
|      * @param returnClosestResult if this search is done to find closest result or all results | ||||
|      * @return NearbyPlacesInfo a variable holds Place list without distance information and | ||||
|      * boundary coordinates of current Place List | ||||
|      */ | ||||
|     public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng curLatLng, | ||||
|     public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng currentLatLng, | ||||
|         final LatLng searchLatLng, | ||||
|         final boolean returnClosestResult, final boolean checkingAroundCurrentLocation) | ||||
|         throws Exception { | ||||
|         return loadAttractionsFromLocation(curLatLng, searchLatLng, returnClosestResult, | ||||
|         return loadAttractionsFromLocation(currentLatLng, searchLatLng, returnClosestResult, | ||||
|             checkingAroundCurrentLocation, null); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * Loads attractions from location for map view, we need to return BaseMarkerOption data type. | ||||
|      * | ||||
|      * @param curLatLng users current location | ||||
|      * @param currentLatLng users current location | ||||
|      * @param placeList list of nearby places in Place data type | ||||
|      * @return BaseMarkerOptions list that holds nearby places | ||||
|      */ | ||||
|     public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions( | ||||
|             LatLng curLatLng, | ||||
|             LatLng currentLatLng, | ||||
|             List<Place> placeList) { | ||||
|         List<BaseMarker> baseMarkersList = new ArrayList<>(); | ||||
| 
 | ||||
|  | @ -245,7 +245,7 @@ public class NearbyController extends MapController { | |||
|         placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS)); | ||||
|         for (Place place : placeList) { | ||||
|             BaseMarker baseMarker = new BaseMarker(); | ||||
|             String distance = formatDistanceBetween(curLatLng, place.location); | ||||
|             String distance = formatDistanceBetween(currentLatLng, place.location); | ||||
|             place.setDistance(distance); | ||||
|             baseMarker.setTitle(place.name); | ||||
|             baseMarker.setPosition( | ||||
|  |  | |||
|  | @ -38,13 +38,13 @@ public class NearbyPlaces { | |||
|     /** | ||||
|      * Expands the radius as needed for the Wikidata query | ||||
|      * | ||||
|      * @param curLatLng           coordinates of search location | ||||
|      * @param currentLatLng           coordinates of search location | ||||
|      * @param lang                user's language | ||||
|      * @param returnClosestResult true if only the nearest point is desired | ||||
|      * @param customQuery | ||||
|      * @return list of places obtained | ||||
|      */ | ||||
|     List<Place> radiusExpander(final LatLng curLatLng, final String lang, | ||||
|     List<Place> radiusExpander(final LatLng currentLatLng, final String lang, | ||||
|         final boolean returnClosestResult, @Nullable final String customQuery) throws Exception { | ||||
| 
 | ||||
|         final int minResults; | ||||
|  | @ -66,7 +66,7 @@ public class NearbyPlaces { | |||
| 
 | ||||
|         // Increase the radius gradually to find a satisfactory number of nearby places | ||||
|         while (radius <= maxRadius) { | ||||
|             places = getFromWikidataQuery(curLatLng, lang, radius, customQuery); | ||||
|             places = getFromWikidataQuery(currentLatLng, lang, radius, customQuery); | ||||
|             Timber.d("%d results at radius: %f", places.size(), radius); | ||||
|             if (places.size() >= minResults) { | ||||
|                 break; | ||||
|  |  | |||
|  | @ -18,9 +18,9 @@ public interface NearbyParentFragmentContract { | |||
| 
 | ||||
|         void listOptionMenuItemClicked(); | ||||
| 
 | ||||
|         void populatePlaces(LatLng curlatLng); | ||||
|         void populatePlaces(LatLng currentLatLng); | ||||
| 
 | ||||
|         void populatePlaces(LatLng curlatLng, String customQuery); | ||||
|         void populatePlaces(LatLng currentLatLng, String customQuery); | ||||
| 
 | ||||
|         boolean isListBottomSheetExpanded(); | ||||
| 
 | ||||
|  | @ -34,7 +34,7 @@ public interface NearbyParentFragmentContract { | |||
| 
 | ||||
|         void animateFABs(); | ||||
| 
 | ||||
|         void recenterMap(LatLng curLatLng); | ||||
|         void recenterMap(LatLng currentLatLng); | ||||
| 
 | ||||
|         void showLocationOffDialog(); | ||||
| 
 | ||||
|  | @ -68,7 +68,7 @@ public interface NearbyParentFragmentContract { | |||
| 
 | ||||
|         void enableFABRecenter(); | ||||
| 
 | ||||
|         void addCurrentLocationMarker(LatLng curLatLng); | ||||
|         void addCurrentLocationMarker(LatLng currentLatLng); | ||||
| 
 | ||||
|         void clearAllMarkers(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -1119,7 +1119,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void populatePlaces(final fr.free.nrw.commons.location.LatLng curlatLng) { | ||||
|     public void populatePlaces(final fr.free.nrw.commons.location.LatLng currentLatLng) { | ||||
|         IGeoPoint screenTopRight = mapView.getProjection().fromPixels(mapView.getWidth(), 0); | ||||
|         IGeoPoint screenBottomLeft = mapView.getProjection().fromPixels(0, mapView.getHeight()); | ||||
|         fr.free.nrw.commons.location.LatLng screenTopRightLatLng = new fr.free.nrw.commons.location.LatLng( | ||||
|  | @ -1139,30 +1139,30 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|             && screenBottomLeftLatLng.getLatitude() == 0.0 | ||||
|             && screenBottomLeftLatLng.getLongitude() == 0.0) { | ||||
|             final double delta = 0.02; | ||||
|             final double westCornerLat = curlatLng.getLatitude() - delta; | ||||
|             final double westCornerLong = curlatLng.getLongitude() - delta; | ||||
|             final double eastCornerLat = curlatLng.getLatitude() + delta; | ||||
|             final double eastCornerLong = curlatLng.getLongitude() + delta; | ||||
|             final double westCornerLat = currentLatLng.getLatitude() - delta; | ||||
|             final double westCornerLong = currentLatLng.getLongitude() - delta; | ||||
|             final double eastCornerLat = currentLatLng.getLatitude() + delta; | ||||
|             final double eastCornerLong = currentLatLng.getLongitude() + delta; | ||||
|             screenTopRightLatLng = new fr.free.nrw.commons.location.LatLng(westCornerLat, | ||||
|                 westCornerLong, 0); | ||||
|             screenBottomLeftLatLng = new fr.free.nrw.commons.location.LatLng(eastCornerLat, | ||||
|                 eastCornerLong, 0); | ||||
|             if (curlatLng.equals( | ||||
|             if (currentLatLng.equals( | ||||
|                 getLastMapFocus())) { // Means we are checking around current location | ||||
|                 populatePlacesForCurrentLocation(getLastMapFocus(), screenTopRightLatLng, | ||||
|                     screenBottomLeftLatLng, curlatLng, null); | ||||
|                     screenBottomLeftLatLng, currentLatLng, null); | ||||
|             } else { | ||||
|                 populatePlacesForAnotherLocation(getLastMapFocus(), screenTopRightLatLng, | ||||
|                     screenBottomLeftLatLng, curlatLng, null); | ||||
|                     screenBottomLeftLatLng, currentLatLng, null); | ||||
|             } | ||||
|         } else { | ||||
|             if (curlatLng.equals( | ||||
|             if (currentLatLng.equals( | ||||
|                 getLastMapFocus())) { // Means we are checking around current location | ||||
|                 populatePlacesForCurrentLocation(getLastMapFocus(), screenTopRightLatLng, | ||||
|                     screenBottomLeftLatLng, curlatLng, null); | ||||
|                     screenBottomLeftLatLng, currentLatLng, null); | ||||
|             } else { | ||||
|                 populatePlacesForAnotherLocation(getLastMapFocus(), screenTopRightLatLng, | ||||
|                     screenBottomLeftLatLng, curlatLng, null); | ||||
|                     screenBottomLeftLatLng, currentLatLng, null); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|  | @ -1172,10 +1172,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void populatePlaces(final fr.free.nrw.commons.location.LatLng curlatLng, | ||||
|     public void populatePlaces(final fr.free.nrw.commons.location.LatLng currentLatLng, | ||||
|         @Nullable final String customQuery) { | ||||
|         if (customQuery == null || customQuery.isEmpty()) { | ||||
|             populatePlaces(curlatLng); | ||||
|             populatePlaces(currentLatLng); | ||||
|             return; | ||||
|         } | ||||
|         IGeoPoint screenTopRight = mapView.getProjection().fromPixels(mapView.getWidth(), 0); | ||||
|  | @ -1185,13 +1185,13 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|         fr.free.nrw.commons.location.LatLng screenBottomLeftLatLng = new fr.free.nrw.commons.location.LatLng( | ||||
|             screenTopRight.getLatitude(), screenTopRight.getLongitude(), 0); | ||||
| 
 | ||||
|         if (curlatLng.equals(lastFocusLocation) || lastFocusLocation == null | ||||
|         if (currentLatLng.equals(lastFocusLocation) || lastFocusLocation == null | ||||
|             || recenterToUserLocation) { // Means we are checking around current location | ||||
|             populatePlacesForCurrentLocation(lastKnownLocation, screenTopRightLatLng, | ||||
|                 screenBottomLeftLatLng, curlatLng, customQuery); | ||||
|                 screenBottomLeftLatLng, currentLatLng, customQuery); | ||||
|         } else { | ||||
|             populatePlacesForAnotherLocation(lastKnownLocation, screenTopRightLatLng, | ||||
|                 screenBottomLeftLatLng, curlatLng, customQuery); | ||||
|                 screenBottomLeftLatLng, currentLatLng, customQuery); | ||||
|         } | ||||
|         if (recenterToUserLocation) { | ||||
|             recenterToUserLocation = false; | ||||
|  | @ -1199,14 +1199,14 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     private void populatePlacesForCurrentLocation( | ||||
|         final fr.free.nrw.commons.location.LatLng curlatLng, | ||||
|         final fr.free.nrw.commons.location.LatLng currentLatLng, | ||||
|         final fr.free.nrw.commons.location.LatLng screenTopRight, | ||||
|         final fr.free.nrw.commons.location.LatLng screenBottomLeft, | ||||
|         final fr.free.nrw.commons.location.LatLng searchLatLng, | ||||
|         @Nullable final String customQuery) { | ||||
|         final Observable<NearbyController.NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable | ||||
|             .fromCallable(() -> nearbyController | ||||
|                 .loadAttractionsFromLocation(curlatLng, screenTopRight, screenBottomLeft, | ||||
|                 .loadAttractionsFromLocation(currentLatLng, screenTopRight, screenBottomLeft, | ||||
|                     searchLatLng, | ||||
|                     false, true, Utils.isMonumentsEnabled(new Date()), customQuery)); | ||||
| 
 | ||||
|  | @ -1234,14 +1234,14 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     private void populatePlacesForAnotherLocation( | ||||
|         final fr.free.nrw.commons.location.LatLng curlatLng, | ||||
|         final fr.free.nrw.commons.location.LatLng currentLatLng, | ||||
|         final fr.free.nrw.commons.location.LatLng screenTopRight, | ||||
|         final fr.free.nrw.commons.location.LatLng screenBottomLeft, | ||||
|         final fr.free.nrw.commons.location.LatLng searchLatLng, | ||||
|         @Nullable final String customQuery) { | ||||
|         final Observable<NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable | ||||
|             .fromCallable(() -> nearbyController | ||||
|                 .loadAttractionsFromLocation(curlatLng, screenTopRight, screenBottomLeft, | ||||
|                 .loadAttractionsFromLocation(currentLatLng, screenTopRight, screenBottomLeft, | ||||
|                     searchLatLng, | ||||
|                     false, true, Utils.isMonumentsEnabled(new Date()), customQuery)); | ||||
| 
 | ||||
|  | @ -1502,15 +1502,15 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|      * Should be called only on creation of Map, there is other method to update markers | ||||
|      * location with users move. | ||||
|      * | ||||
|      * @param curLatLng current location | ||||
|      * @param currentLatLng current location | ||||
|      */ | ||||
|     @Override | ||||
|     public void addCurrentLocationMarker(final fr.free.nrw.commons.location.LatLng curLatLng) { | ||||
|         if (null != curLatLng && !isPermissionDenied && locationManager.isGPSProviderEnabled()) { | ||||
|     public void addCurrentLocationMarker(final fr.free.nrw.commons.location.LatLng currentLatLng) { | ||||
|         if (null != currentLatLng && !isPermissionDenied && locationManager.isGPSProviderEnabled()) { | ||||
|             ExecutorUtils.get().submit(() -> { | ||||
|                 Timber.d("Adds current location marker"); | ||||
|                 recenterMarkerToPosition( | ||||
|                     new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); | ||||
|                     new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude())); | ||||
|             }); | ||||
|         } else { | ||||
|             Timber.d("not adding current location marker..current location is null"); | ||||
|  | @ -1612,10 +1612,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|      * | ||||
|      * @param isBookmarked true if place is bookmarked | ||||
|      * @param place | ||||
|      * @param curLatLng    current location | ||||
|      * @param currentLatLng    current location | ||||
|      */ | ||||
|     public void updateMarker(final boolean isBookmarked, final Place place, | ||||
|         @Nullable final fr.free.nrw.commons.location.LatLng curLatLng) { | ||||
|         @Nullable final fr.free.nrw.commons.location.LatLng currentLatLng) { | ||||
|         addMarkerToMap(place, isBookmarked); | ||||
|     } | ||||
| 
 | ||||
|  | @ -1765,8 +1765,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void recenterMap(fr.free.nrw.commons.location.LatLng curLatLng) { | ||||
|         if (isPermissionDenied || curLatLng == null) { | ||||
|     public void recenterMap(fr.free.nrw.commons.location.LatLng currentLatLng) { | ||||
|         if (isPermissionDenied || currentLatLng == null) { | ||||
|             recenterToUserLocation = true; | ||||
|             checkPermissionsAndPerformAction(); | ||||
|             if (!isPermissionDenied && !(locationManager.isNetworkProviderEnabled() | ||||
|  | @ -1775,9 +1775,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment | |||
|             } | ||||
|             return; | ||||
|         } | ||||
|         addCurrentLocationMarker(curLatLng); | ||||
|         addCurrentLocationMarker(currentLatLng); | ||||
|         mapView.getController() | ||||
|             .animateTo(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); | ||||
|             .animateTo(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude())); | ||||
|         if (lastMapFocus != null) { | ||||
|             Location mylocation = new Location(""); | ||||
|             Location dest_location = new Location(""); | ||||
|  |  | |||
|  | @ -38,7 +38,7 @@ public class NearbyParentFragmentPresenter | |||
|     LocationUpdateListener { | ||||
| 
 | ||||
|     private boolean isNearbyLocked; | ||||
|     private LatLng curLatLng; | ||||
|     private LatLng currentLatLng; | ||||
| 
 | ||||
|     private boolean placesLoadedOnce; | ||||
| 
 | ||||
|  | @ -111,7 +111,7 @@ public class NearbyParentFragmentPresenter | |||
|         }); | ||||
| 
 | ||||
|         nearbyParentFragmentView.setFABRecenterAction(v -> { | ||||
|             nearbyParentFragmentView.recenterMap(curLatLng); | ||||
|             nearbyParentFragmentView.recenterMap(currentLatLng); | ||||
|         }); | ||||
| 
 | ||||
|     } | ||||
|  | @ -172,11 +172,11 @@ public class NearbyParentFragmentPresenter | |||
| 
 | ||||
|         LatLng lastLocation = nearbyParentFragmentView.getLastMapFocus(); | ||||
|         if (nearbyParentFragmentView.getMapCenter() != null) { | ||||
|             curLatLng = nearbyParentFragmentView.getMapCenter(); | ||||
|             currentLatLng = nearbyParentFragmentView.getMapCenter(); | ||||
|         } else { | ||||
|             curLatLng = lastLocation; | ||||
|             currentLatLng = lastLocation; | ||||
|         } | ||||
|         if (curLatLng == null) { | ||||
|         if (currentLatLng == null) { | ||||
|             Timber.d("Skipping update of nearby places as location is unavailable"); | ||||
|             return; | ||||
|         } | ||||
|  | @ -220,7 +220,7 @@ public class NearbyParentFragmentPresenter | |||
|         if (null != nearbyParentFragmentView) { | ||||
|             nearbyParentFragmentView.clearAllMarkers(); | ||||
|             List<BaseMarker> baseMarkers = NearbyController | ||||
|                 .loadAttractionsFromLocationToBaseMarkerOptions(nearbyPlacesInfo.curLatLng, | ||||
|                 .loadAttractionsFromLocationToBaseMarkerOptions(nearbyPlacesInfo.currentLatLng, | ||||
|                     // Curlatlang will be used to calculate distances | ||||
|                     nearbyPlacesInfo.placeList); | ||||
|             nearbyParentFragmentView.updateMapMarkers(baseMarkers); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 bugfixer4646
						bugfixer4646