Skip to content

Resolves #5444 & #5455 updating nearest item distance and direction as user moves #5459

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ public class ContributionsFragment

private LatLng curLatLng;

private boolean firstLocationUpdate = true;
private boolean isFragmentAttachedBefore = false;
private View checkBoxView;
private CheckBox checkBox;
Expand Down Expand Up @@ -453,7 +452,6 @@ public void onSaveInstanceState(Bundle outState) {
public void onResume() {
super.onResume();
contributionsPresenter.onAttachView(this);
firstLocationUpdate = true;
locationManager.addLocationListener(this);
nearbyNotificationCardView.permissionRequestButton.setOnClickListener(v -> {
showNearbyCardPermissionRationale();
Expand Down Expand Up @@ -572,22 +570,17 @@ public void onDestroy() {
@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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
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;
Expand Down