mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +01:00
Updating nearby banner on slight location change (#5459)
This commit is contained in:
parent
cbf022d2f2
commit
2c086b3d79
2 changed files with 5 additions and 12 deletions
|
|
@ -118,7 +118,6 @@ public class ContributionsFragment
|
|||
|
||||
private LatLng curLatLng;
|
||||
|
||||
private boolean firstLocationUpdate = true;
|
||||
private boolean isFragmentAttachedBefore = false;
|
||||
private View checkBoxView;
|
||||
private CheckBox checkBox;
|
||||
|
|
@ -453,7 +452,6 @@ public class ContributionsFragment
|
|||
public void onResume() {
|
||||
super.onResume();
|
||||
contributionsPresenter.onAttachView(this);
|
||||
firstLocationUpdate = true;
|
||||
locationManager.addLocationListener(this);
|
||||
nearbyNotificationCardView.permissionRequestButton.setOnClickListener(v -> {
|
||||
showNearbyCardPermissionRationale();
|
||||
|
|
@ -572,22 +570,17 @@ public class ContributionsFragment
|
|||
@Override
|
||||
public void onLocationChangedSignificantly(LatLng latLng) {
|
||||
// Will be called if location changed more than 1000 meter
|
||||
// Do nothing on slight changes for using network efficiently
|
||||
firstLocationUpdate = false;
|
||||
updateClosestNearbyCardViewInfo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLocationChangedSlightly(LatLng latLng) {
|
||||
/* Update closest nearby notification card onLocationChangedSlightly
|
||||
If first time to update location after onResume, then no need to wait for significant
|
||||
location change. Any closest location is better than no location
|
||||
*/
|
||||
if (firstLocationUpdate) {
|
||||
try {
|
||||
updateClosestNearbyCardViewInfo();
|
||||
// Turn it to false, since it is not first location update anymore. To change closest location
|
||||
// notification, we need to wait for a significant location change.
|
||||
firstLocationUpdate = false;
|
||||
} catch (Exception e) {
|
||||
Timber.e(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ import timber.log.Timber;
|
|||
public class LocationServiceManager implements LocationListener {
|
||||
|
||||
// Maybe these values can be improved for efficiency
|
||||
private static final long MIN_LOCATION_UPDATE_REQUEST_TIME_IN_MILLIS = 2 * 60 * 100;
|
||||
private static final long MIN_LOCATION_UPDATE_REQUEST_DISTANCE_IN_METERS = 10;
|
||||
private static final long MIN_LOCATION_UPDATE_REQUEST_TIME_IN_MILLIS = 10 * 100;
|
||||
private static final long MIN_LOCATION_UPDATE_REQUEST_DISTANCE_IN_METERS = 1;
|
||||
|
||||
private LocationManager locationManager;
|
||||
private Location lastLocation;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue