Cleaner telegram update configuration.
Distance between updates has also been set to only 1000 meters.
This commit is contained in:
parent
4734104bd2
commit
6cefb98c9b
|
|
@ -32,6 +32,9 @@ public class LocationLoggingService extends Service implements LocationListener
|
||||||
private LocationDao locationDao;
|
private LocationDao locationDao;
|
||||||
private Location lastLocation;
|
private Location lastLocation;
|
||||||
|
|
||||||
|
Duration durationBetweenTelegramUpdates = Duration.ofMinutes(6);
|
||||||
|
long metersDistanceBetweenTelegramUpdates = 1000;
|
||||||
|
|
||||||
public LocationLoggingService() {
|
public LocationLoggingService() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -98,14 +101,13 @@ public class LocationLoggingService extends Service implements LocationListener
|
||||||
|
|
||||||
if(lastLocation != null)
|
if(lastLocation != null)
|
||||||
{
|
{
|
||||||
if(newLocation.distanceTo(lastLocation) < 2000) {
|
if(newLocation.distanceTo(lastLocation) < metersDistanceBetweenTelegramUpdates) {
|
||||||
Log.d(TAG, "Distance to last location too short. Ignoring.");
|
Log.d(TAG, "Distance to last location too short. Ignoring.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
long oldTime = lastLocation.getTime();
|
long oldTime = lastLocation.getTime();
|
||||||
long newTime = newLocation.getTime();
|
long newTime = newLocation.getTime();
|
||||||
Duration durationBetweenUpdates = Duration.ofMinutes(6);
|
|
||||||
|
|
||||||
if(oldTime > newTime)
|
if(oldTime > newTime)
|
||||||
{
|
{
|
||||||
|
|
@ -114,7 +116,7 @@ public class LocationLoggingService extends Service implements LocationListener
|
||||||
}
|
}
|
||||||
|
|
||||||
long millisSinceLastUpdate = newTime - oldTime;
|
long millisSinceLastUpdate = newTime - oldTime;
|
||||||
if(durationBetweenUpdates.toMillis() > millisSinceLastUpdate)
|
if(durationBetweenTelegramUpdates.toMillis() > millisSinceLastUpdate)
|
||||||
{
|
{
|
||||||
Log.d(TAG, "Location update is too recent.");
|
Log.d(TAG, "Location update is too recent.");
|
||||||
return;
|
return;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue