Fix first usage wizard

This commit is contained in:
Alexey Kulish 2016-11-19 16:55:48 +03:00
parent b33eac33fe
commit c4f9819353

View file

@ -692,13 +692,15 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
} }
public static void startWizard(FragmentActivity activity) { public static void startWizard(FragmentActivity activity) {
OsmandApplication app = (OsmandApplication) activity.getApplication(); if (activity != null) {
if (!app.getSettings().isInternetConnectionAvailable()) { OsmandApplication app = (OsmandApplication) activity.getApplication();
showNoInternetFragment(activity); if (!app.getSettings().isInternetConnectionAvailable()) {
} else if (location == null) { showNoInternetFragment(activity);
findLocation(activity, true); } else if (location == null) {
} else { findLocation(activity, true);
showSearchMapFragment(activity); } else {
showSearchMapFragment(activity);
}
} }
} }
@ -730,19 +732,21 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
} }
private static void findLocation(FragmentActivity activity, boolean searchLocationByIp) { private static void findLocation(FragmentActivity activity, boolean searchLocationByIp) {
OsmandApplication app = (OsmandApplication) activity.getApplication(); if (activity != null) {
if (searchLocationByIp) { OsmandApplication app = (OsmandApplication) activity.getApplication();
showSearchLocationFragment(activity, true); if (searchLocationByIp) {
} else if (OsmAndLocationProvider.isLocationPermissionAvailable(activity)) { showSearchLocationFragment(activity, true);
Location loc = app.getLocationProvider().getLastKnownLocation(); } else if (OsmAndLocationProvider.isLocationPermissionAvailable(activity)) {
if (loc == null) { Location loc = app.getLocationProvider().getLastKnownLocation();
showSearchLocationFragment(activity, false); if (loc == null) {
showSearchLocationFragment(activity, false);
} else {
location = new Location(loc);
showSearchMapFragment(activity);
}
} else { } else {
location = new Location(loc); showSearchLocationFragment(activity, false);
showSearchMapFragment(activity);
} }
} else {
showSearchLocationFragment(activity, false);
} }
} }
@ -870,7 +874,7 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
} }
private static void showFragment(FragmentActivity activity, Fragment fragment) { private static void showFragment(FragmentActivity activity, Fragment fragment) {
if (!wizardClosed) { if (!wizardClosed && activity != null) {
activity.getSupportFragmentManager() activity.getSupportFragmentManager()
.beginTransaction() .beginTransaction()
.replace(R.id.fragmentContainer, fragment, FirstUsageWizardFragment.TAG) .replace(R.id.fragmentContainer, fragment, FirstUsageWizardFragment.TAG)