mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Merge pull request #575 from maskaravivek/crashFix
Fix Crash issue when GPS location is not available
This commit is contained in:
commit
1d0dad9e1a
1 changed files with 26 additions and 9 deletions
|
|
@ -66,6 +66,17 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
Bundle savedInstanceState) {
|
Bundle savedInstanceState) {
|
||||||
|
|
||||||
|
if (curLatLng != null) {
|
||||||
|
setupMapView(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
setHasOptionsMenu(false);
|
||||||
|
|
||||||
|
return mapView;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setupMapView(Bundle savedInstanceState) {
|
||||||
MapboxMapOptions options = new MapboxMapOptions()
|
MapboxMapOptions options = new MapboxMapOptions()
|
||||||
.styleUrl(Style.OUTDOORS)
|
.styleUrl(Style.OUTDOORS)
|
||||||
.camera(new CameraPosition.Builder()
|
.camera(new CameraPosition.Builder()
|
||||||
|
|
@ -99,10 +110,6 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
||||||
} else {
|
} else {
|
||||||
mapView.setStyleUrl(getResources().getString(R.string.map_theme_light));
|
mapView.setStyleUrl(getResources().getString(R.string.map_theme_light));
|
||||||
}
|
}
|
||||||
|
|
||||||
setHasOptionsMenu(false);
|
|
||||||
|
|
||||||
return mapView;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -112,31 +119,41 @@ public class NearbyMapFragment extends android.support.v4.app.Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
mapView.onStart();
|
if (mapView != null) {
|
||||||
|
mapView.onStart();
|
||||||
|
}
|
||||||
super.onStart();
|
super.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
mapView.onPause();
|
if (mapView != null) {
|
||||||
|
mapView.onPause();
|
||||||
|
}
|
||||||
super.onPause();
|
super.onPause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
mapView.onResume();
|
if (mapView != null) {
|
||||||
|
mapView.onResume();
|
||||||
|
}
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
mapView.onStop();
|
if (mapView != null) {
|
||||||
|
mapView.onStop();
|
||||||
|
}
|
||||||
super.onStop();
|
super.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
mapView.onDestroy();
|
if (mapView != null) {
|
||||||
|
mapView.onDestroy();
|
||||||
|
}
|
||||||
super.onDestroyView();
|
super.onDestroyView();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue