clear map did not work properly after orientation change - treat network and gps locations differently

This commit is contained in:
y20k 2016-09-26 14:43:01 +02:00
parent 60a5ba5b5a
commit 4f1017ced9
2 changed files with 12 additions and 3 deletions

View file

@ -384,11 +384,13 @@ public class MainActivityMapFragment extends Fragment implements TrackbookKeys {
/* Removes track crumbs from map */
public void clearMap() {
// TODO clear map or clear intent
// clear map
if (mTrackOverlay != null) {
Toast.makeText(mActivity, mActivity.getString(R.string.toast_message_clear_map), Toast.LENGTH_LONG).show();
mMapView.getOverlays().remove(mTrackOverlay);
}
// clear track object
mTrack = null;
}

View file

@ -140,8 +140,15 @@ public final class LocationHelper implements TrackbookKeys {
float distance = newLocation.distanceTo(lastLocation);
long timeDifference = newLocation.getElapsedRealtimeNanos() - lastLocation.getElapsedRealtimeNanos();
// distance is bigger than 10 meters and time difference bigger than 12 seconds
return distance > 10 && timeDifference >= TWELVE_SECONDS_IN_NANOSECONDS;
// TODO check for sudden location jump errors
if (newLocation.getProvider().equals(LocationManager.GPS_PROVIDER)) {
// CASE GPS: distance is bigger than 10 meters and time difference bigger than 12 seconds
return distance > 10 && timeDifference >= TWELVE_SECONDS_IN_NANOSECONDS;
} else {
// CASE network: distance is bigger than 50 meters and time difference bigger than 12 seconds
return distance > 50 && timeDifference >= TWELVE_SECONDS_IN_NANOSECONDS;
}
}