mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
* 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:
parent
a4a037a577
commit
bedc53b0ca
2 changed files with 20 additions and 4 deletions
|
|
@ -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)
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -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
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue