Skip to content

Commit a45ab9c

Browse files
aahlad2000Aahlad
andauthored
Refactor curlatLng to currentLatLng (commons-app#5646)
Co-authored-by: Aahlad <[email protected]>
1 parent cd337b0 commit a45ab9c

14 files changed

+102
-102
lines changed

app/src/main/java/fr/free/nrw/commons/MapController.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public abstract class MapController {
1212
public class NearbyPlacesInfo {
1313
public List<Place> placeList; // List of nearby places
1414
public LatLng[] boundaryCoordinates; // Corners of nearby area
15-
public LatLng curLatLng; // Current ___location when this places are populated
15+
public LatLng currentLatLng; // Current ___location when this places are populated
1616
public LatLng searchLatLng; // Search ___location for finding this places
1717
public List<Media> mediaList; // Search ___location for finding this places
1818
}
@@ -23,7 +23,7 @@ public class NearbyPlacesInfo {
2323
public class ExplorePlacesInfo {
2424
public List<Place> explorePlaceList; // List of nearby places
2525
public LatLng[] boundaryCoordinates; // Corners of nearby area
26-
public LatLng curLatLng; // Current ___location when this places are populated
26+
public LatLng currentLatLng; // Current ___location when this places are populated
2727
public LatLng searchLatLng; // Search ___location for finding this places
2828
public List<Media> mediaList; // Search ___location for finding this places
2929
}

app/src/main/java/fr/free/nrw/commons/contributions/ContributionsFragment.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public class ContributionsFragment
121121
@Inject
122122
SessionManager sessionManager;
123123

124-
private LatLng curLatLng;
124+
private LatLng currentLatLng;
125125

126126
private boolean isFragmentAttachedBefore = false;
127127
private View checkBoxView;
@@ -542,9 +542,9 @@ private void displayYouWontSeeNearbyMessage() {
542542

543543

544544
private void updateClosestNearbyCardViewInfo() {
545-
curLatLng = locationManager.getLastLocation();
545+
currentLatLng = locationManager.getLastLocation();
546546
compositeDisposable.add(Observable.fromCallable(() -> nearbyController
547-
.loadAttractionsFromLocation(curLatLng, curLatLng, true,
547+
.loadAttractionsFromLocation(currentLatLng, currentLatLng, true,
548548
false)) // thanks to boolean, it will only return closest result
549549
.subscribeOn(Schedulers.io())
550550
.observeOn(AndroidSchedulers.mainThread())
@@ -571,9 +571,9 @@ private void updateNearbyNotification(
571571
if (closestNearbyPlace == null) {
572572
binding.cardViewNearby.setVisibility(View.GONE);
573573
} else {
574-
String distance = formatDistanceBetween(curLatLng, closestNearbyPlace.___location);
574+
String distance = formatDistanceBetween(currentLatLng, closestNearbyPlace.___location);
575575
closestNearbyPlace.setDistance(distance);
576-
direction = (float) computeBearing(curLatLng, closestNearbyPlace.___location);
576+
direction = (float) computeBearing(currentLatLng, closestNearbyPlace.___location);
577577
binding.cardViewNearby.updateContent(closestNearbyPlace);
578578
}
579579
} else {

app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapCalls.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public ExploreMapCalls() {
2020
/**
2121
* Calls method to query Commons for uploads around a ___location
2222
*
23-
* @param curLatLng coordinates of search ___location
23+
* @param currentLatLng coordinates of search ___location
2424
* @return list of places obtained
2525
*/
26-
List<Media> callCommonsQuery(final LatLng curLatLng) {
27-
String coordinates = curLatLng.getLatitude() + "|" + curLatLng.getLongitude();
26+
List<Media> callCommonsQuery(final LatLng currentLatLng) {
27+
String coordinates = currentLatLng.getLatitude() + "|" + currentLatLng.getLongitude();
2828
return mediaClient.getMediaListFromGeoSearch(coordinates).blockingGet();
2929
}
3030

app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapContract.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ public class ExploreMapContract {
1111

1212
interface View {
1313
boolean isNetworkConnectionEstablished();
14-
void populatePlaces(LatLng curlatLng);
14+
void populatePlaces(LatLng currentLatLng);
1515
void checkPermissionsAndPerformAction();
16-
void recenterMap(LatLng curLatLng);
16+
void recenterMap(LatLng currentLatLng);
1717
void showLocationOffDialog();
1818
void openLocationSettings();
1919
void hideBottomDetailsSheet();

app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapController.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@ public ExploreMapController(ExploreMapCalls explorePlaces) {
4545
}
4646

4747
/**
48-
* Takes ___location as parameter and returns ExplorePlaces info that holds curLatLng, mediaList,
48+
* Takes ___location as parameter and returns ExplorePlaces info that holds currentLatLng, mediaList,
4949
* explorePlaceList and boundaryCoordinates
5050
*
51-
* @param curLatLng is current geolocation
51+
* @param currentLatLng is current geolocation
5252
* @param searchLatLng is the ___location that we want to search around
5353
* @param checkingAroundCurrentLocation is a boolean flag. True if we want to check around
5454
* current ___location, false if another ___location
55-
* @return explorePlacesInfo info that holds curLatLng, mediaList, explorePlaceList and
55+
* @return explorePlacesInfo info that holds currentLatLng, mediaList, explorePlaceList and
5656
* boundaryCoordinates
5757
*/
58-
public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng searchLatLng,
58+
public ExplorePlacesInfo loadAttractionsFromLocation(LatLng currentLatLng, LatLng searchLatLng,
5959
boolean checkingAroundCurrentLocation) {
6060

6161
if (searchLatLng == null) {
@@ -65,7 +65,7 @@ public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng se
6565

6666
ExplorePlacesInfo explorePlacesInfo = new ExplorePlacesInfo();
6767
try {
68-
explorePlacesInfo.curLatLng = curLatLng;
68+
explorePlacesInfo.currentLatLng = currentLatLng;
6969
latestSearchLocation = searchLatLng;
7070

7171
List<Media> mediaList = exploreMapCalls.callCommonsQuery(searchLatLng);
@@ -115,7 +115,7 @@ public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng se
115115
// Our radius searched around us, will be used to understand when user search their own ___location, we will follow them
116116
if (checkingAroundCurrentLocation) {
117117
currentLocationSearchRadius = latestSearchRadius;
118-
currentLocation = curLatLng;
118+
currentLocation = currentLatLng;
119119
}
120120
} catch (Exception e) {
121121
e.printStackTrace();
@@ -129,7 +129,7 @@ public ExplorePlacesInfo loadAttractionsFromLocation(LatLng curLatLng, LatLng se
129129
* @return baseMarkerOptions list that holds nearby places with their icons
130130
*/
131131
public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
132-
LatLng curLatLng,
132+
LatLng currentLatLng,
133133
final List<Place> placeList,
134134
Context context,
135135
NearbyBaseMarkerThumbCallback callback,
@@ -151,7 +151,7 @@ public static List<BaseMarker> loadAttractionsFromLocationToBaseMarkerOptions(
151151
if (vectorDrawable != null) {
152152
for (Place explorePlace : placeList) {
153153
final BaseMarker baseMarker = new BaseMarker();
154-
String distance = formatDistanceBetween(curLatLng, explorePlace.___location);
154+
String distance = formatDistanceBetween(currentLatLng, explorePlace.___location);
155155
explorePlace.setDistance(distance);
156156

157157
baseMarker.setTitle(

app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapFragment.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -391,18 +391,18 @@ public boolean isNetworkConnectionEstablished() {
391391
}
392392

393393
@Override
394-
public void populatePlaces(LatLng curLatLng) {
394+
public void populatePlaces(LatLng currentLatLng) {
395395
final Observable<MapController.ExplorePlacesInfo> nearbyPlacesInfoObservable;
396-
if (curLatLng == null) {
396+
if (currentLatLng == null) {
397397
checkPermissionsAndPerformAction();
398398
return;
399399
}
400-
if (curLatLng.equals(getLastMapFocus())) { // Means we are checking around current ___location
401-
nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(curLatLng,
400+
if (currentLatLng.equals(getLastMapFocus())) { // Means we are checking around current ___location
401+
nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(currentLatLng,
402402
getLastMapFocus(), true);
403403
} else {
404404
nearbyPlacesInfoObservable = presenter.loadAttractionsFromLocation(getLastMapFocus(),
405-
curLatLng, false);
405+
currentLatLng, false);
406406
}
407407
compositeDisposable.add(nearbyPlacesInfoObservable
408408
.subscribeOn(Schedulers.io())
@@ -413,7 +413,7 @@ public void populatePlaces(LatLng curLatLng) {
413413
showResponseMessage(getString(R.string.no_pictures_in_this_area));
414414
}
415415
updateMapMarkers(explorePlacesInfo);
416-
lastMapFocus = new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude());
416+
lastMapFocus = new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude());
417417
},
418418
throwable -> {
419419
Timber.d(throwable);
@@ -479,8 +479,8 @@ public void registerUnregisterLocationListener(final boolean removeLocationListe
479479
}
480480

481481
@Override
482-
public void recenterMap(LatLng curLatLng) {
483-
if (isPermissionDenied || curLatLng == null) {
482+
public void recenterMap(LatLng currentLatLng) {
483+
if (isPermissionDenied || currentLatLng == null) {
484484
recenterToUserLocation = true;
485485
checkPermissionsAndPerformAction();
486486
if (!isPermissionDenied && !(locationManager.isNetworkProviderEnabled()
@@ -489,9 +489,9 @@ public void recenterMap(LatLng curLatLng) {
489489
}
490490
return;
491491
}
492-
recenterMarkerToPosition(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()));
492+
recenterMarkerToPosition(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude()));
493493
binding.mapView.getController()
494-
.animateTo(new GeoPoint(curLatLng.getLatitude(), curLatLng.getLongitude()));
494+
.animateTo(new GeoPoint(currentLatLng.getLatitude(), currentLatLng.getLongitude()));
495495
if (lastMapFocus != null) {
496496
Location mylocation = new Location("");
497497
Location dest_location = new Location("");

app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapPresenter.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public class ExploreMapPresenter
2525

2626
BookmarkLocationsDao bookmarkLocationDao;
2727
private boolean isNearbyLocked;
28-
private LatLng curLatLng;
28+
private LatLng currentLatLng;
2929
private ExploreMapController exploreMapController;
3030

3131
private static final ExploreMapContract.View DUMMY = (ExploreMapContract.View) Proxy
@@ -119,7 +119,7 @@ public void detachView() {
119119
@Override
120120
public void setActionListeners(JsonKvStore applicationKvStore) {
121121
exploreMapFragmentView.setFABRecenterAction(v -> {
122-
exploreMapFragmentView.recenterMap(curLatLng);
122+
exploreMapFragmentView.recenterMap(currentLatLng);
123123
});
124124

125125
}
@@ -144,11 +144,11 @@ public void initializeMapOperations() {
144144
exploreMapFragmentView.addSearchThisAreaButtonAction();
145145
}
146146

147-
public Observable<ExplorePlacesInfo> loadAttractionsFromLocation(LatLng curLatLng,
147+
public Observable<ExplorePlacesInfo> loadAttractionsFromLocation(LatLng currentLatLng,
148148
LatLng searchLatLng, boolean checkingAroundCurrent) {
149149
return Observable
150150
.fromCallable(() -> exploreMapController
151-
.loadAttractionsFromLocation(curLatLng, searchLatLng, checkingAroundCurrent));
151+
.loadAttractionsFromLocation(currentLatLng, searchLatLng, checkingAroundCurrent));
152152
}
153153

154154
/**
@@ -169,7 +169,7 @@ public void updateMapMarkers(
169169

170170
void prepareNearbyBaseMarkers(MapController.ExplorePlacesInfo explorePlacesInfo) {
171171
exploreMapController
172-
.loadAttractionsFromLocationToBaseMarkerOptions(explorePlacesInfo.curLatLng,
172+
.loadAttractionsFromLocationToBaseMarkerOptions(explorePlacesInfo.currentLatLng,
173173
// Curlatlang will be used to calculate distances
174174
explorePlacesInfo.explorePlaceList,
175175
exploreMapFragmentView.getContext(),

0 commit comments

Comments
 (0)