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

master
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
// 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;
}
}