Skip to content
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

[openweathermap] Do not update the discovery inbox while the location is unchanged #8078

Merged
merged 1 commit into from
Jul 7, 2020
Merged
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 @@ -79,7 +79,7 @@ public void deactivate() {
@Override
protected void startScan() {
logger.debug("Start manual OpenWeatherMap Location discovery scan.");
scanForNewLocation();
scanForNewLocation(false);
}

@Override
Expand All @@ -93,8 +93,9 @@ protected void startBackgroundDiscovery() {
if (discoveryJob == null || discoveryJob.isCancelled()) {
logger.debug("Start OpenWeatherMap Location background discovery job at interval {} s.",
DISCOVERY_INTERVAL_SECONDS);
discoveryJob = scheduler.scheduleWithFixedDelay(this::scanForNewLocation, 0, DISCOVERY_INTERVAL_SECONDS,
TimeUnit.SECONDS);
discoveryJob = scheduler.scheduleWithFixedDelay(() -> {
scanForNewLocation(true);
}, 0, DISCOVERY_INTERVAL_SECONDS, TimeUnit.SECONDS);
}
}

Expand All @@ -108,7 +109,7 @@ protected void stopBackgroundDiscovery() {
}
}

private void scanForNewLocation() {
private void scanForNewLocation(boolean updateOnlyIfNewLocation) {
PointType currentLocation = locationProvider.getLocation();
if (currentLocation == null) {
logger.debug("Location is not set -> Will not provide any discovery results.");
Expand All @@ -117,7 +118,7 @@ private void scanForNewLocation() {
currentLocation);
createResults(currentLocation);
previousLocation = currentLocation;
} else {
} else if (!updateOnlyIfNewLocation) {
createResults(currentLocation);
}
}
Expand Down