Refactor curlatLng to currentLatLng (#5646)

Co-authored-by: Aahlad <aahladkethineeedi@gmail.com>
This commit is contained in:
bugfixer4646 2024-03-25 07:05:30 +05:30 committed by GitHub
parent cd337b000e
commit a45ab9cf16
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 102 additions and 102 deletions

View file

@ -12,7 +12,7 @@ public abstract class MapController {
public class NearbyPlacesInfo { public class NearbyPlacesInfo {
public List<Place> placeList; // List of nearby places public List<Place> placeList; // List of nearby places
public LatLng[] boundaryCoordinates; // Corners of nearby area 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 LatLng searchLatLng; // Search location for finding this places
public List<Media> mediaList; // 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 class ExplorePlacesInfo {
public List<Place> explorePlaceList; // List of nearby places public List<Place> explorePlaceList; // List of nearby places
public LatLng[] boundaryCoordinates; // Corners of nearby area 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 LatLng searchLatLng; // Search location for finding this places
public List<Media> mediaList; // Search location for finding this places public List<Media> mediaList; // Search location for finding this places
} }

View file

@ -121,7 +121,7 @@ public class ContributionsFragment
@Inject @Inject
SessionManager sessionManager; SessionManager sessionManager;
private LatLng curLatLng; private LatLng currentLatLng;
private boolean isFragmentAttachedBefore = false; private boolean isFragmentAttachedBefore = false;
private View checkBoxView; private View checkBoxView;
@ -542,9 +542,9 @@ public class ContributionsFragment
private void updateClosestNearbyCardViewInfo() { private void updateClosestNearbyCardViewInfo() {
curLatLng = locationManager.getLastLocation(); currentLatLng = locationManager.getLastLocation();
compositeDisposable.add(Observable.fromCallable(() -> nearbyController compositeDisposable.add(Observable.fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curLatLng, curLatLng, true, .loadAttractionsFromLocation(currentLatLng, currentLatLng, true,
false)) // thanks to boolean, it will only return closest result false)) // thanks to boolean, it will only return closest result
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
@ -571,9 +571,9 @@ public class ContributionsFragment
if (closestNearbyPlace == null) { if (closestNearbyPlace == null) {
binding.cardViewNearby.setVisibility(View.GONE); binding.cardViewNearby.setVisibility(View.GONE);
} else { } else {
String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.location); String distance = formatDistanceBetween(currentLatLng, closestNearbyPlace.location);
closestNearbyPlace.setDistance(distance); closestNearbyPlace.setDistance(distance);
direction = (float) computeBearing(curLatLng, closestNearbyPlace.location); direction = (float) computeBearing(currentLatLng, closestNearbyPlace.location);
binding.cardViewNearby.updateContent(closestNearbyPlace); binding.cardViewNearby.updateContent(closestNearbyPlace);
} }
} else { } else {

View file

@ -20,11 +20,11 @@ public class ExploreMapCalls {
/** /**
* Calls method to query Commons for uploads around a location * 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 * @return list of places obtained
*/ */
List<Media> callCommonsQuery(final LatLng curLatLng) { List<Media> callCommonsQuery(final LatLng currentLatLng) {
String coordinates = curLatLng.getLatitude() + "|" + curLatLng.getLongitude(); String coordinates = currentLatLng.getLatitude() + "|" + currentLatLng.getLongitude();
return mediaClient.getMediaListFromGeoSearch(coordinates).blockingGet(); return mediaClient.getMediaListFromGeoSearch(coordinates).blockingGet();
} }

View file

@ -11,9 +11,9 @@ public class ExploreMapContract {
interface View { interface View {
boolean isNetworkConnectionEstablished(); boolean isNetworkConnectionEstablished();
void populatePlaces(LatLng curlatLng); void populatePlaces(LatLng currentLatLng);
void checkPermissionsAndPerformAction(); void checkPermissionsAndPerformAction();
void recenterMap(LatLng curLatLng); void recenterMap(LatLng currentLatLng);
void showLocationOffDialog(); void showLocationOffDialog();
void openLocationSettings(); void openLocationSettings();
void hideBottomDetailsSheet(); void hideBottomDetailsSheet();

View file

@ -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 * 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 searchLatLng is the location that we want to search around
* @param checkingAroundCurrentLocation is a boolean flag. True if we want to check around * @param checkingAroundCurrentLocation is a boolean flag. True if we want to check around
* current location, false if another location * 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 * boundaryCoordinates
*/ */
public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng searchLatLng, public ExplorePlacesInfo loadAttractionsFromLocation(LatLng currentLatLng, LatLng searchLatLng,
boolean checkingAroundCurrentLocation) { boolean checkingAroundCurrentLocation) {
if (searchLatLng == null) { if (searchLatLng == null) {
@ -65,7 +65,7 @@ public class ExploreMapController extends MapController {
ExplorePlacesInfo explorePlacesInfo = new ExplorePlacesInfo(); ExplorePlacesInfo explorePlacesInfo = new ExplorePlacesInfo();
try { try {
explorePlacesInfo.curLatLng = curLatLng; explorePlacesInfo.currentLatLng = currentLatLng;
latestSearchLocation = searchLatLng; latestSearchLocation = searchLatLng;
List<Media> mediaList = exploreMapCalls.callCommonsQuery(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 // Our radius searched around us, will be used to understand when user search their own location, we will follow them
if (checkingAroundCurrentLocation) { if (checkingAroundCurrentLocation) {
currentLocationSearchRadius = latestSearchRadius; currentLocationSearchRadius = latestSearchRadius;
currentLocation = curLatLng; currentLocation = currentLatLng;
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
@ -129,7 +129,7 @@ public class ExploreMapController extends MapController {
* @return baseMarkerOptions list that holds nearby places with their icons * @return baseMarkerOptions list that holds nearby places with their icons
*/ */
public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions( public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
LatLng curLatLng, LatLng currentLatLng,
final List<Place> placeList, final List<Place> placeList,
Context context, Context context,
NearbyBaseMarkerThumbCallback callback, NearbyBaseMarkerThumbCallback callback,
@ -151,7 +151,7 @@ public class ExploreMapController extends MapController {
if (vectorDrawable != null) { if (vectorDrawable != null) {
for (Place explorePlace : placeList) { for (Place explorePlace : placeList) {
final BaseMarker baseMarker = new BaseMarker(); final BaseMarker baseMarker = new BaseMarker();
String distance = formatDistanceBetween(curLatLng, explorePlace.location); String distance = formatDistanceBetween(currentLatLng, explorePlace.location);
explorePlace.setDistance(distance); explorePlace.setDistance(distance);
baseMarker.setTitle( baseMarker.setTitle(

View file

@ -391,18 +391,18 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
} }
@Override @Override
public void populatePlaces(LatLng curLatLng) { public void populatePlaces(LatLng currentLatLng) {
final Observable<MapController.ExplorePlacesInfo> nearbyPlacesInfoObservable; final Observable<MapController.ExplorePlacesInfo> nearbyPlacesInfoObservable;
if (curLatLng == null) { if (currentLatLng == null) {
checkPermissionsAndPerformAction(); checkPermissionsAndPerformAction();
return; return;
} }
if (curLatLng.equals(getLastMapFocus())) { // Means we are checking around current location if (currentLatLng.equals(getLastMapFocus())) { // Means we are checking around current location
nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(curLatLng, nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(currentLatLng,
getLastMapFocus(), true); getLastMapFocus(), true);
} else { } else {
nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(getLastMapFocus(), nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(getLastMapFocus(),
curLatLng, false); currentLatLng, false);
} }
compositeDisposable.add(nearbyPlacesInfoObservable compositeDisposable.add(nearbyPlacesInfoObservable
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
@ -413,7 +413,7 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
showResponseMessage(getString(R.string.no_pictures_in_this_area)); showResponseMessage(getString(R.string.no_pictures_in_this_area));
} }
updateMapMarkers(explorePlacesInfo); updateMapMarkers(explorePlacesInfo);
lastMapFocus = new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()); lastMapFocus = new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude());
}, },
throwable -> { throwable -> {
Timber.d(throwable); Timber.d(throwable);
@ -479,8 +479,8 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
} }
@Override @Override
public void recenterMap(LatLng curLatLng) { public void recenterMap(LatLng currentLatLng) {
if (isPermissionDenied || curLatLng == null) { if (isPermissionDenied || currentLatLng == null) {
recenterToUserLocation = true; recenterToUserLocation = true;
checkPermissionsAndPerformAction(); checkPermissionsAndPerformAction();
if (!isPermissionDenied && !(locationManager.isNetworkProviderEnabled() if (!isPermissionDenied && !(locationManager.isNetworkProviderEnabled()
@ -489,9 +489,9 @@ public class ExploreMapFragment extends CommonsDaggerSupportFragment
} }
return; return;
} }
recenterMarkerToPosition(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); recenterMarkerToPosition(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude()));
binding.mapView.getController() binding.mapView.getController()
.animateTo(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); .animateTo(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude()));
if (lastMapFocus != null) { if (lastMapFocus != null) {
Location mylocation = new Location(""); Location mylocation = new Location("");
Location dest_location = new Location(""); Location dest_location = new Location("");

View file

@ -25,7 +25,7 @@ public class ExploreMapPresenter
BookmarkLocationsDao bookmarkLocationDao; BookmarkLocationsDao bookmarkLocationDao;
private boolean isNearbyLocked; private boolean isNearbyLocked;
private LatLng curLatLng; private LatLng currentLatLng;
private ExploreMapController exploreMapController; private ExploreMapController exploreMapController;
private static final ExploreMapContract.View DUMMY = (ExploreMapContract.View) Proxy private static final ExploreMapContract.View DUMMY = (ExploreMapContract.View) Proxy
@ -119,7 +119,7 @@ public class ExploreMapPresenter
@Override @Override
public void setActionListeners(JsonKvStore applicationKvStore) { public void setActionListeners(JsonKvStore applicationKvStore) {
exploreMapFragmentView.setFABRecenterAction(v -> { exploreMapFragmentView.setFABRecenterAction(v -> {
exploreMapFragmentView.recenterMap(curLatLng); exploreMapFragmentView.recenterMap(currentLatLng);
}); });
} }
@ -144,11 +144,11 @@ public class ExploreMapPresenter
exploreMapFragmentView.addSearchThisAreaButtonAction(); exploreMapFragmentView.addSearchThisAreaButtonAction();
} }
public Observable<ExplorePlacesInfo> loadAttractionsFromLocation(LatLng curLatLng, public Observable<ExplorePlacesInfo> loadAttractionsFromLocation(LatLng currentLatLng,
LatLng searchLatLng, boolean checkingAroundCurrent) { LatLng searchLatLng, boolean checkingAroundCurrent) {
return Observable return Observable
.fromCallable(() -> exploreMapController .fromCallable(() -> exploreMapController
.loadAttractionsFromLocation(curLatLng, searchLatLng, checkingAroundCurrent)); .loadAttractionsFromLocation(currentLatLng, searchLatLng, checkingAroundCurrent));
} }
/** /**
@ -169,7 +169,7 @@ public class ExploreMapPresenter
void prepareNearbyBaseMarkers(MapController.ExplorePlacesInfo explorePlacesInfo) { void prepareNearbyBaseMarkers(MapController.ExplorePlacesInfo explorePlacesInfo) {
exploreMapController exploreMapController
.loadAttractionsFromLocationToBaseMarkerOptions(explorePlacesInfo.curLatLng, .loadAttractionsFromLocationToBaseMarkerOptions(explorePlacesInfo.currentLatLng,
// Curlatlang will be used to calculate distances // Curlatlang will be used to calculate distances
explorePlacesInfo.explorePlaceList, explorePlacesInfo.explorePlaceList,
exploreMapFragmentView.getContext(), exploreMapFragmentView.getContext(),

View file

@ -39,14 +39,14 @@ public class NearbyController extends MapController {
/** /**
* Prepares Place list to make their distance information update later. * 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 searchLatLng the location user wants to search around
* @param returnClosestResult if this search is done to find closest result or all results * @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 * @param customQuery if this search is done via an advanced query
* @return NearbyPlacesInfo a variable holds Place list without distance information and * @return NearbyPlacesInfo a variable holds Place list without distance information and
* boundary coordinates of current Place List * boundary coordinates of current Place List
*/ */
public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng curLatLng, public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng currentLatLng,
final LatLng searchLatLng, final LatLng searchLatLng,
final boolean returnClosestResult, final boolean checkingAroundCurrentLocation, final boolean returnClosestResult, final boolean checkingAroundCurrentLocation,
@Nullable final String customQuery) throws Exception { @Nullable final String customQuery) throws Exception {
@ -54,7 +54,7 @@ public class NearbyController extends MapController {
Timber.d("Loading attractions near %s", searchLatLng); Timber.d("Loading attractions near %s", searchLatLng);
NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo(); NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo();
if (searchLatLng == null) { if (searchLatLng == null) {
Timber.d("Loading attractions nearby, but curLatLng is null"); Timber.d("Loading attractions nearby, but currentLatLng is null");
return null; return null;
} }
List<Place> places = nearbyPlaces List<Place> places = nearbyPlaces
@ -68,11 +68,11 @@ public class NearbyController extends MapController {
places.get(0).location, // west places.get(0).location, // west
places.get(0).location};// east, init with a random location places.get(0).location};// east, init with a random location
if (curLatLng != null) { if (currentLatLng != null) {
Timber.d("Sorting places by distance..."); Timber.d("Sorting places by distance...");
final Map<Place, Double> distances = new HashMap<>(); final Map<Place, Double> distances = new HashMap<>();
for (Place place : places) { 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 // Find boundaries with basic find max approach
if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) { if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) {
boundaryCoordinates[0] = place.location; boundaryCoordinates[0] = place.location;
@ -95,7 +95,7 @@ public class NearbyController extends MapController {
} }
); );
} }
nearbyPlacesInfo.curLatLng = curLatLng; nearbyPlacesInfo.currentLatLng = currentLatLng;
nearbyPlacesInfo.searchLatLng = searchLatLng; nearbyPlacesInfo.searchLatLng = searchLatLng;
nearbyPlacesInfo.placeList = places; nearbyPlacesInfo.placeList = places;
nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates; 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 // Our radius searched around us, will be used to understand when user search their own location, we will follow them
if (checkingAroundCurrentLocation) { if (checkingAroundCurrentLocation) {
currentLocationSearchRadius = nearbyPlaces.radius * 1000; // to meter 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. * 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, * @param screenTopRight The top right corner of the screen (latitude,
* longitude). * longitude).
* @param screenBottomLeft The bottom left corner of the screen (latitude, * @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. * @return An object containing information about nearby places.
* @throws Exception If an error occurs during the retrieval process. * @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 screenTopRight,
final fr.free.nrw.commons.location.LatLng screenBottomLeft, final LatLng searchLatLng, final fr.free.nrw.commons.location.LatLng screenBottomLeft, final LatLng searchLatLng,
final boolean returnClosestResult, final boolean checkingAroundCurrentLocation, final boolean returnClosestResult, final boolean checkingAroundCurrentLocation,
@ -148,7 +148,7 @@ public class NearbyController extends MapController {
NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo(); NearbyPlacesInfo nearbyPlacesInfo = new NearbyPlacesInfo();
if (searchLatLng == null) { if (searchLatLng == null) {
Timber.d("Loading attractions nearby, but curLatLng is null"); Timber.d("Loading attractions nearby, but currentLatLng is null");
return null; return null;
} }
@ -162,11 +162,11 @@ public class NearbyController extends MapController {
places.get(0).location, // west places.get(0).location, // west
places.get(0).location};// east, init with a random location places.get(0).location};// east, init with a random location
if (curLatLng != null) { if (currentLatLng != null) {
Timber.d("Sorting places by distance..."); Timber.d("Sorting places by distance...");
final Map<Place, Double> distances = new HashMap<>(); final Map<Place, Double> distances = new HashMap<>();
for (Place place : places) { 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 // Find boundaries with basic find max approach
if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) { if (place.location.getLatitude() < boundaryCoordinates[0].getLatitude()) {
boundaryCoordinates[0] = place.location; boundaryCoordinates[0] = place.location;
@ -189,7 +189,7 @@ public class NearbyController extends MapController {
} }
); );
} }
nearbyPlacesInfo.curLatLng = curLatLng; nearbyPlacesInfo.currentLatLng = currentLatLng;
nearbyPlacesInfo.searchLatLng = searchLatLng; nearbyPlacesInfo.searchLatLng = searchLatLng;
nearbyPlacesInfo.placeList = places; nearbyPlacesInfo.placeList = places;
nearbyPlacesInfo.boundaryCoordinates = boundaryCoordinates; 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 // Our radius searched around us, will be used to understand when user search their own location, we will follow them
if (checkingAroundCurrentLocation) { if (checkingAroundCurrentLocation) {
currentLocationSearchRadius = nearbyPlaces.radius * 1000; // to meter 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. * 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 searchLatLng the location user wants to search around
* @param returnClosestResult if this search is done to find closest result or all results * @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 * @return NearbyPlacesInfo a variable holds Place list without distance information and
* boundary coordinates of current Place List * boundary coordinates of current Place List
*/ */
public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng curLatLng, public NearbyPlacesInfo loadAttractionsFromLocation(final LatLng currentLatLng,
final LatLng searchLatLng, final LatLng searchLatLng,
final boolean returnClosestResult, final boolean checkingAroundCurrentLocation) final boolean returnClosestResult, final boolean checkingAroundCurrentLocation)
throws Exception { throws Exception {
return loadAttractionsFromLocation(curLatLng, searchLatLng, returnClosestResult, return loadAttractionsFromLocation(currentLatLng, searchLatLng, returnClosestResult,
checkingAroundCurrentLocation, null); checkingAroundCurrentLocation, null);
} }
/** /**
* Loads attractions from location for map view, we need to return BaseMarkerOption data type. * 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 * @param placeList list of nearby places in Place data type
* @return BaseMarkerOptions list that holds nearby places * @return BaseMarkerOptions list that holds nearby places
*/ */
public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions( public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
LatLng curLatLng, LatLng currentLatLng,
List<Place> placeList) { List<Place> placeList) {
List<BaseMarker> baseMarkersList = new ArrayList<>(); List<BaseMarker> baseMarkersList = new ArrayList<>();
@ -245,7 +245,7 @@ public class NearbyController extends MapController {
placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS)); placeList = placeList.subList(0, Math.min(placeList.size(), MAX_RESULTS));
for (Place place : placeList) { for (Place place : placeList) {
BaseMarker baseMarker = new BaseMarker(); BaseMarker baseMarker = new BaseMarker();
String distance = formatDistanceBetween(curLatLng, place.location); String distance = formatDistanceBetween(currentLatLng, place.location);
place.setDistance(distance); place.setDistance(distance);
baseMarker.setTitle(place.name); baseMarker.setTitle(place.name);
baseMarker.setPosition( baseMarker.setPosition(

View file

@ -38,13 +38,13 @@ public class NearbyPlaces {
/** /**
* Expands the radius as needed for the Wikidata query * 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 lang user's language
* @param returnClosestResult true if only the nearest point is desired * @param returnClosestResult true if only the nearest point is desired
* @param customQuery * @param customQuery
* @return list of places obtained * @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 boolean returnClosestResult, @Nullable final String customQuery) throws Exception {
final int minResults; final int minResults;
@ -66,7 +66,7 @@ public class NearbyPlaces {
// Increase the radius gradually to find a satisfactory number of nearby places // Increase the radius gradually to find a satisfactory number of nearby places
while (radius <= maxRadius) { 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); Timber.d("%d results at radius: %f", places.size(), radius);
if (places.size() >= minResults) { if (places.size() >= minResults) {
break; break;

View file

@ -18,9 +18,9 @@ public interface NearbyParentFragmentContract {
void listOptionMenuItemClicked(); void listOptionMenuItemClicked();
void populatePlaces(LatLng curlatLng); void populatePlaces(LatLng currentLatLng);
void populatePlaces(LatLng curlatLng, String customQuery); void populatePlaces(LatLng currentLatLng, String customQuery);
boolean isListBottomSheetExpanded(); boolean isListBottomSheetExpanded();
@ -34,7 +34,7 @@ public interface NearbyParentFragmentContract {
void animateFABs(); void animateFABs();
void recenterMap(LatLng curLatLng); void recenterMap(LatLng currentLatLng);
void showLocationOffDialog(); void showLocationOffDialog();
@ -68,7 +68,7 @@ public interface NearbyParentFragmentContract {
void enableFABRecenter(); void enableFABRecenter();
void addCurrentLocationMarker(LatLng curLatLng); void addCurrentLocationMarker(LatLng currentLatLng);
void clearAllMarkers(); void clearAllMarkers();

View file

@ -1119,7 +1119,7 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
} }
@Override @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 screenTopRight = mapView.getProjection().fromPixels(mapView.getWidth(), 0);
IGeoPoint screenBottomLeft = mapView.getProjection().fromPixels(0, mapView.getHeight()); IGeoPoint screenBottomLeft = mapView.getProjection().fromPixels(0, mapView.getHeight());
fr.free.nrw.commons.location.LatLng screenTopRightLatLng = new fr.free.nrw.commons.location.LatLng( 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.getLatitude() == 0.0
&& screenBottomLeftLatLng.getLongitude() == 0.0) { && screenBottomLeftLatLng.getLongitude() == 0.0) {
final double delta = 0.02; final double delta = 0.02;
final double westCornerLat = curlatLng.getLatitude() - delta; final double westCornerLat = currentLatLng.getLatitude() - delta;
final double westCornerLong = curlatLng.getLongitude() - delta; final double westCornerLong = currentLatLng.getLongitude() - delta;
final double eastCornerLat = curlatLng.getLatitude() + delta; final double eastCornerLat = currentLatLng.getLatitude() + delta;
final double eastCornerLong = curlatLng.getLongitude() + delta; final double eastCornerLong = currentLatLng.getLongitude() + delta;
screenTopRightLatLng = new fr.free.nrw.commons.location.LatLng(westCornerLat, screenTopRightLatLng = new fr.free.nrw.commons.location.LatLng(westCornerLat,
westCornerLong, 0); westCornerLong, 0);
screenBottomLeftLatLng = new fr.free.nrw.commons.location.LatLng(eastCornerLat, screenBottomLeftLatLng = new fr.free.nrw.commons.location.LatLng(eastCornerLat,
eastCornerLong, 0); eastCornerLong, 0);
if (curlatLng.equals( if (currentLatLng.equals(
getLastMapFocus())) { // Means we are checking around current location getLastMapFocus())) { // Means we are checking around current location
populatePlacesForCurrentLocation(getLastMapFocus(), screenTopRightLatLng, populatePlacesForCurrentLocation(getLastMapFocus(), screenTopRightLatLng,
screenBottomLeftLatLng, curlatLng, null); screenBottomLeftLatLng, currentLatLng, null);
} else { } else {
populatePlacesForAnotherLocation(getLastMapFocus(), screenTopRightLatLng, populatePlacesForAnotherLocation(getLastMapFocus(), screenTopRightLatLng,
screenBottomLeftLatLng, curlatLng, null); screenBottomLeftLatLng, currentLatLng, null);
} }
} else { } else {
if (curlatLng.equals( if (currentLatLng.equals(
getLastMapFocus())) { // Means we are checking around current location getLastMapFocus())) { // Means we are checking around current location
populatePlacesForCurrentLocation(getLastMapFocus(), screenTopRightLatLng, populatePlacesForCurrentLocation(getLastMapFocus(), screenTopRightLatLng,
screenBottomLeftLatLng, curlatLng, null); screenBottomLeftLatLng, currentLatLng, null);
} else { } else {
populatePlacesForAnotherLocation(getLastMapFocus(), screenTopRightLatLng, populatePlacesForAnotherLocation(getLastMapFocus(), screenTopRightLatLng,
screenBottomLeftLatLng, curlatLng, null); screenBottomLeftLatLng, currentLatLng, null);
} }
} }
@ -1172,10 +1172,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
} }
@Override @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) { @Nullable final String customQuery) {
if (customQuery == null || customQuery.isEmpty()) { if (customQuery == null || customQuery.isEmpty()) {
populatePlaces(curlatLng); populatePlaces(currentLatLng);
return; return;
} }
IGeoPoint screenTopRight = mapView.getProjection().fromPixels(mapView.getWidth(), 0); 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( fr.free.nrw.commons.location.LatLng screenBottomLeftLatLng = new fr.free.nrw.commons.location.LatLng(
screenTopRight.getLatitude(), screenTopRight.getLongitude(), 0); 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 || recenterToUserLocation) { // Means we are checking around current location
populatePlacesForCurrentLocation(lastKnownLocation, screenTopRightLatLng, populatePlacesForCurrentLocation(lastKnownLocation, screenTopRightLatLng,
screenBottomLeftLatLng, curlatLng, customQuery); screenBottomLeftLatLng, currentLatLng, customQuery);
} else { } else {
populatePlacesForAnotherLocation(lastKnownLocation, screenTopRightLatLng, populatePlacesForAnotherLocation(lastKnownLocation, screenTopRightLatLng,
screenBottomLeftLatLng, curlatLng, customQuery); screenBottomLeftLatLng, currentLatLng, customQuery);
} }
if (recenterToUserLocation) { if (recenterToUserLocation) {
recenterToUserLocation = false; recenterToUserLocation = false;
@ -1199,14 +1199,14 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
} }
private void populatePlacesForCurrentLocation( 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 screenTopRight,
final fr.free.nrw.commons.location.LatLng screenBottomLeft, final fr.free.nrw.commons.location.LatLng screenBottomLeft,
final fr.free.nrw.commons.location.LatLng searchLatLng, final fr.free.nrw.commons.location.LatLng searchLatLng,
@Nullable final String customQuery) { @Nullable final String customQuery) {
final Observable<NearbyController.NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable final Observable<NearbyController.NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable
.fromCallable(() -> nearbyController .fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curlatLng, screenTopRight, screenBottomLeft, .loadAttractionsFromLocation(currentLatLng, screenTopRight, screenBottomLeft,
searchLatLng, searchLatLng,
false, true, Utils.isMonumentsEnabled(new Date()), customQuery)); false, true, Utils.isMonumentsEnabled(new Date()), customQuery));
@ -1234,14 +1234,14 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
} }
private void populatePlacesForAnotherLocation( 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 screenTopRight,
final fr.free.nrw.commons.location.LatLng screenBottomLeft, final fr.free.nrw.commons.location.LatLng screenBottomLeft,
final fr.free.nrw.commons.location.LatLng searchLatLng, final fr.free.nrw.commons.location.LatLng searchLatLng,
@Nullable final String customQuery) { @Nullable final String customQuery) {
final Observable<NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable final Observable<NearbyPlacesInfo> nearbyPlacesInfoObservable = Observable
.fromCallable(() -> nearbyController .fromCallable(() -> nearbyController
.loadAttractionsFromLocation(curlatLng, screenTopRight, screenBottomLeft, .loadAttractionsFromLocation(currentLatLng, screenTopRight, screenBottomLeft,
searchLatLng, searchLatLng,
false, true, Utils.isMonumentsEnabled(new Date()), customQuery)); 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 * Should be called only on creation of Map, there is other method to update markers
* location with users move. * location with users move.
* *
* @param curLatLng current location * @param currentLatLng current location
*/ */
@Override @Override
public void addCurrentLocationMarker(final fr.free.nrw.commons.location.LatLng curLatLng) { public void addCurrentLocationMarker(final fr.free.nrw.commons.location.LatLng currentLatLng) {
if (null != curLatLng && !isPermissionDenied && locationManager.isGPSProviderEnabled()) { if (null != currentLatLng && !isPermissionDenied && locationManager.isGPSProviderEnabled()) {
ExecutorUtils.get().submit(() -> { ExecutorUtils.get().submit(() -> {
Timber.d("Adds current location marker"); Timber.d("Adds current location marker");
recenterMarkerToPosition( recenterMarkerToPosition(
new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude()));
}); });
} else { } else {
Timber.d("not adding current location marker..current location is null"); 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 isBookmarked true if place is bookmarked
* @param place * @param place
* @param curLatLng current location * @param currentLatLng current location
*/ */
public void updateMarker(final boolean isBookmarked, final Place place, 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); addMarkerToMap(place, isBookmarked);
} }
@ -1765,8 +1765,8 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
} }
@Override @Override
public void recenterMap(fr.free.nrw.commons.location.LatLng curLatLng) { public void recenterMap(fr.free.nrw.commons.location.LatLng currentLatLng) {
if (isPermissionDenied || curLatLng == null) { if (isPermissionDenied || currentLatLng == null) {
recenterToUserLocation = true; recenterToUserLocation = true;
checkPermissionsAndPerformAction(); checkPermissionsAndPerformAction();
if (!isPermissionDenied && !(locationManager.isNetworkProviderEnabled() if (!isPermissionDenied && !(locationManager.isNetworkProviderEnabled()
@ -1775,9 +1775,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
} }
return; return;
} }
addCurrentLocationMarker(curLatLng); addCurrentLocationMarker(currentLatLng);
mapView.getController() mapView.getController()
.animateTo(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude())); .animateTo(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude()));
if (lastMapFocus != null) { if (lastMapFocus != null) {
Location mylocation = new Location(""); Location mylocation = new Location("");
Location dest_location = new Location(""); Location dest_location = new Location("");

View file

@ -38,7 +38,7 @@ public class NearbyParentFragmentPresenter
LocationUpdateListener { LocationUpdateListener {
private boolean isNearbyLocked; private boolean isNearbyLocked;
private LatLng curLatLng; private LatLng currentLatLng;
private boolean placesLoadedOnce; private boolean placesLoadedOnce;
@ -111,7 +111,7 @@ public class NearbyParentFragmentPresenter
}); });
nearbyParentFragmentView.setFABRecenterAction(v -> { nearbyParentFragmentView.setFABRecenterAction(v -> {
nearbyParentFragmentView.recenterMap(curLatLng); nearbyParentFragmentView.recenterMap(currentLatLng);
}); });
} }
@ -172,11 +172,11 @@ public class NearbyParentFragmentPresenter
LatLng lastLocation = nearbyParentFragmentView.getLastMapFocus(); LatLng lastLocation = nearbyParentFragmentView.getLastMapFocus();
if (nearbyParentFragmentView.getMapCenter() != null) { if (nearbyParentFragmentView.getMapCenter() != null) {
curLatLng = nearbyParentFragmentView.getMapCenter(); currentLatLng = nearbyParentFragmentView.getMapCenter();
} else { } else {
curLatLng = lastLocation; currentLatLng = lastLocation;
} }
if (curLatLng == null) { if (currentLatLng == null) {
Timber.d("Skipping update of nearby places as location is unavailable"); Timber.d("Skipping update of nearby places as location is unavailable");
return; return;
} }
@ -220,7 +220,7 @@ public class NearbyParentFragmentPresenter
if (null != nearbyParentFragmentView) { if (null != nearbyParentFragmentView) {
nearbyParentFragmentView.clearAllMarkers(); nearbyParentFragmentView.clearAllMarkers();
List<BaseMarker> baseMarkers = NearbyController List<BaseMarker> baseMarkers = NearbyController
.loadAttractionsFromLocationToBaseMarkerOptions(nearbyPlacesInfo.curLatLng, .loadAttractionsFromLocationToBaseMarkerOptions(nearbyPlacesInfo.currentLatLng,
// Curlatlang will be used to calculate distances // Curlatlang will be used to calculate distances
nearbyPlacesInfo.placeList); nearbyPlacesInfo.placeList);
nearbyParentFragmentView.updateMapMarkers(baseMarkers); nearbyParentFragmentView.updateMapMarkers(baseMarkers);

View file

@ -168,7 +168,7 @@ class NearbyControllerTest {
false, false,
customQuery customQuery
) )
assertEquals(result.curLatLng, currentLatLng) assertEquals(result.currentLatLng, currentLatLng)
assertEquals(result.searchLatLng, searchLatLong) assertEquals(result.searchLatLng, searchLatLong)
} }
@ -209,7 +209,7 @@ class NearbyControllerTest {
true, true,
customQuery customQuery
) )
assertEquals(result.curLatLng, currentLatLng) assertEquals(result.currentLatLng, currentLatLng)
assertEquals(result.searchLatLng, searchLatLong) assertEquals(result.searchLatLng, searchLatLong)
} }
@ -250,7 +250,7 @@ class NearbyControllerTest {
true, true,
customQuery customQuery
) )
assertEquals(result.curLatLng, currentLatLng) assertEquals(result.currentLatLng, currentLatLng)
assertEquals(result.searchLatLng, searchLatLong) assertEquals(result.searchLatLng, searchLatLong)
} }

View file

@ -478,7 +478,7 @@ class NearbyParentFragmentPresenterTest {
whenever(latestLocation.accuracy).thenReturn(0.0F) whenever(latestLocation.accuracy).thenReturn(0.0F)
var nearbyPlacesInfo = NearbyController(nearbyPlaces).NearbyPlacesInfo() var nearbyPlacesInfo = NearbyController(nearbyPlaces).NearbyPlacesInfo()
nearbyPlacesInfo.boundaryCoordinates = arrayOf() nearbyPlacesInfo.boundaryCoordinates = arrayOf()
nearbyPlacesInfo.curLatLng = latestLocation nearbyPlacesInfo.currentLatLng = latestLocation
nearbyPlacesInfo.searchLatLng = latestLocation nearbyPlacesInfo.searchLatLng = latestLocation
nearbyPlacesInfo.placeList = null nearbyPlacesInfo.placeList = null