Add callback for slightly change option to listener

This commit is contained in:
neslihanturan 2018-02-19 23:29:17 +03:00
parent 581483e4ca
commit cda75348d2
3 changed files with 20 additions and 8 deletions

View file

@ -136,11 +136,11 @@ public class LocationServiceManager implements LocationListener {
} else {
return LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED;
}
// If the new location is more than two minutes older, it must be worse
// If the new location is more than two minutes older, it must be worse
} else{
Log.d("deneme","distance:"+results[0]);
return LocationChangeType.LOCATION_NOT_CHANGED;
}
}
}
@ -178,14 +178,20 @@ public class LocationServiceManager implements LocationListener {
@Override
public void onLocationChanged(Location location) {
Log.d("deneme","location changed");
if (isBetterLocation(location, lastLocation)) {
if (isBetterLocation(location, lastLocation)
.equals(LocationChangeType.LOCATION_SIGNIFICANTLY_CHANGED)) {
Log.d("deneme","location changed better location");
lastLocation = location;
for (LocationUpdateListener listener : locationListeners) {
listener.onLocationChanged(LatLng.from(lastLocation));
listener.onLocationChangedSignificantly(LatLng.from(lastLocation));
}
} else if (isBetterLocation(location, lastLocation)
.equals(LocationChangeType.LOCATION_SLIGHTLY_CHANGED)) {
Log.d("deneme","location changed better location");
lastLocation = location;
for (LocationUpdateListener listener : locationListeners) {
listener.onLocationChangedSlightly(LatLng.from(lastLocation));
}
} else {
Log.d("deneme","location changed worse location");
}
}

View file

@ -1,5 +1,6 @@
package fr.free.nrw.commons.location;
public interface LocationUpdateListener {
void onLocationChanged(LatLng latLng);
void onLocationChangedSignificantly(LatLng latLng);
void onLocationChangedSlightly(LatLng latLng);
}

View file

@ -392,7 +392,12 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
}
@Override
public void onLocationChanged(LatLng latLng) {
public void onLocationChangedSignificantly(LatLng latLng) {
refreshView(false);
}
@Override
public void onLocationChangedSlightly(LatLng latLng) {
refreshView(false);
}