Fixes: map not centering to current position at on resume.

This commit is contained in:
Bennet Brunsen committed 2015-03-31 12:35:24 +02:00
1 parent a441ad2b52
commit 76fb0b1e80
1 file changed
+10 -6
@@ -44,6 +44,7 @@ public class BuoyFragment extends BaseFragment implements LocationListener {
private LocationManager locationManager;
private pingListener pingListener;
private SignalQualityIndicatorView signalQualityIndicatorView;
private boolean initialLocationUpdate;
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -80,21 +81,17 @@ public class BuoyFragment extends BaseFragment implements LocationListener {
@Override
public void onResume() {
super.onResume();
initialLocationUpdate = true;
initLocationProvider();
String locationProvider = locationManager.getBestProvider(new Criteria(), true);
lastKnownLocation = locationManager.getLastKnownLocation(locationProvider);
MarkInfo mark = ((PositioningActivity) getActivity()).getMarkInfo();
reportGPSQuality(GPSQuality.noSignal.toInt());
if (mark != null) {
markHeaderTextView.setText(mark.getName());
setUpTextUI(lastKnownLocation);
setUpMap();
}
if (lastKnownLocation != null) {
LatLng lastKnownLatLng = new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude());
mapFragment.getMap().animateCamera(CameraUpdateFactory.newLatLngZoom(lastKnownLatLng, 15));
setPositionButton.setVisibility(View.VISIBLE);
reportGPSQuality(lastKnownLocation.getAccuracy());
}
}
@Override
@@ -142,6 +139,13 @@ public class BuoyFragment extends BaseFragment implements LocationListener {
setUpTextUI(lastKnownLocation);
setUpMap();
}
if(initialLocationUpdate){
LatLng lastKnownLatLng = new LatLng(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude());
mapFragment.getMap().animateCamera(CameraUpdateFactory.newLatLngZoom(lastKnownLatLng, 15));
initialLocationUpdate = false;
}
}
@Override