Skip to content

Commit bedc53b

Browse files
neslihanturanmisaochan
authored andcommitted
Fixes commons-app#2062 Nearby: My position does not move (commons-app#2235)
* Add method to check if current location marker is in visible region or not * Ignore postion track updates if current location marker is not in the visible region * Fix unnecessary progess bar issue
1 parent a4a037a commit bedc53b

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

app/src/main/java/fr/free/nrw/commons/nearby/NearbyFragment.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -444,9 +444,6 @@ private void lockNearbyView(boolean lock) {
444444
* @param nearbyPlacesInfo Includes nearby places list and boundary coordinates
445445
*/
446446
private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate, @Nullable LatLng customLatLng, @Nullable NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
447-
if (nearbyMapFragment.checkingAround) {
448-
return;
449-
}
450447
/*
451448
Significant update means updating nearby place markers. Slightly update means only
452449
updating current location marker and camera target.
@@ -456,6 +453,13 @@ private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate,
456453
*/
457454
NearbyMapFragment nearbyMapFragment = getMapFragment();
458455

456+
if (nearbyMapFragment != null && !nearbyMapFragment.isCurrentLocationMarkerVisible()) {
457+
Timber.d("Do not update the map, user is not seeing current location marker" +
458+
" means they are checking around and moving on map");
459+
return;
460+
}
461+
462+
459463
if (nearbyMapFragment != null && curLatLng != null) {
460464
hideProgressBar(); // In case it is visible (this happens, not an impossible case)
461465
/*

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ private void addMapMovementListeners() {
580580
searchThisAreaModeOn = true;
581581
// Lock map operations during search this area operation
582582
mapboxMap.getUiSettings().setAllGesturesEnabled(false);
583-
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
583+
searchThisAreaButtonProgressBar.setVisibility(View.GONE);
584584
fabRecenter.callOnClick();
585585
searchThisAreaButton.setVisibility(View.GONE);
586586
searchedAroundCurrentLocation = true;
@@ -646,6 +646,18 @@ private void addCurrentLocationMarker(MapboxMap mapboxMap) {
646646
mapboxMap.addPolygon(currentLocationPolygonOptions);
647647
}
648648

649+
/**
650+
* Checks whether current location marker is in visible region or not
651+
* @return true if point is in region
652+
*/
653+
public boolean isCurrentLocationMarkerVisible() {
654+
if (currentLocationMarker != null) {
655+
return mapboxMap.getProjection().getVisibleRegion().latLngBounds.contains(currentLocationMarker.getPosition());
656+
} else {
657+
return false;
658+
}
659+
}
660+
649661
/**
650662
* Adds markers for nearby places to mapbox map
651663
*/

0 commit comments

Comments
 (0)