fixed distance

This commit is contained in:
Sem van der Hoeven
2021-01-06 13:57:00 +01:00
parent bd623a3f1d
commit 216f48cc0f

View File

@@ -316,11 +316,13 @@ public class HomeFragment extends Fragment implements LocationListener {
@Override
public void onLocationChanged(@NonNull Location location) {
// calculate the distance walked
if (currentLocation != null && currentLocation.getLatitude() != 0 && currentLocation.getLongitude() != 0) {
double distance = currentLocation.distanceTo(location); // in meters
double distance = currentLocation.distanceTo(location); // in meters
// can't walk 100 meters in a few seconds
if (distance < 100)
StaticData.INSTANCE.addDistance(distance);
currentLocation = location;
}
currentLocation = location;
//new thread because we don't want the main thread to hang, this method gets called a lot
Thread t = new Thread(() -> {