Fixes #2062 Nearby: My position does not move (#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
This commit is contained in:
neslihanturan 2019-01-03 16:28:11 +02:00 committed by Josephine Lim
parent a4a037a577
commit bedc53b0ca
2 changed files with 20 additions and 4 deletions

View file

@ -444,9 +444,6 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
* @param nearbyPlacesInfo Includes nearby places list and boundary coordinates
*/
private void updateMapFragment(boolean updateViaButton, boolean isSlightUpdate, @Nullable LatLng customLatLng, @Nullable NearbyController.NearbyPlacesInfo nearbyPlacesInfo) {
if (nearbyMapFragment.checkingAround) {
return;
}
/*
Significant update means updating nearby place markers. Slightly update means only
updating current location marker and camera target.
@ -456,6 +453,13 @@ public class NearbyFragment extends CommonsDaggerSupportFragment
*/
NearbyMapFragment nearbyMapFragment = getMapFragment();
if (nearbyMapFragment != null && !nearbyMapFragment.isCurrentLocationMarkerVisible()) {
Timber.d("Do not update the map, user is not seeing current location marker" +
" means they are checking around and moving on map");
return;
}
if (nearbyMapFragment != null && curLatLng != null) {
hideProgressBar(); // In case it is visible (this happens, not an impossible case)
/*

View file

@ -580,7 +580,7 @@ public class NearbyMapFragment extends DaggerFragment {
searchThisAreaModeOn = true;
// Lock map operations during search this area operation
mapboxMap.getUiSettings().setAllGesturesEnabled(false);
searchThisAreaButtonProgressBar.setVisibility(View.VISIBLE);
searchThisAreaButtonProgressBar.setVisibility(View.GONE);
fabRecenter.callOnClick();
searchThisAreaButton.setVisibility(View.GONE);
searchedAroundCurrentLocation = true;
@ -646,6 +646,18 @@ public class NearbyMapFragment extends DaggerFragment {
mapboxMap.addPolygon(currentLocationPolygonOptions);
}
/**
* Checks whether current location marker is in visible region or not
* @return true if point is in region
*/
public boolean isCurrentLocationMarkerVisible() {
if (currentLocationMarker != null) {
return mapboxMap.getProjection().getVisibleRegion().latLngBounds.contains(currentLocationMarker.getPosition());
} else {
return false;
}
}
/**
* Adds markers for nearby places to mapbox map
*/