Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2016-08-17 22:34:15 +02:00
commit 93ed67630a

View file

@ -300,8 +300,8 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
@Override @Override
protected String doInBackground(Void... params) { protected String doInBackground(Void... params) {
try { try {
return AndroidNetworkUtils.sendRequest(app, return AndroidNetworkUtils.sendRequest(app, "http://osmand.net/api/geo-ip", null,
"http://osmand.net/api/geo-ip", null, "Requesting location by IP...", false); "Requesting location by IP...", false);
} catch (Exception e) { } catch (Exception e) {
logError("Requesting location by IP error: ", e); logError("Requesting location by IP error: ", e);
@ -316,11 +316,14 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
JSONObject obj = new JSONObject(response); JSONObject obj = new JSONObject(response);
double latitude = obj.getDouble("latitude"); double latitude = obj.getDouble("latitude");
double longitude = obj.getDouble("longitude"); double longitude = obj.getDouble("longitude");
if (latitude == 0 && longitude == 0) {
showNoLocationFragment(getActivity());
} else {
location = new Location("geo-ip"); location = new Location("geo-ip");
location.setLatitude(latitude); location.setLatitude(latitude);
location.setLongitude(longitude); location.setLongitude(longitude);
showSearchMapFragment(getActivity()); showSearchMapFragment(getActivity());
}
} catch (Exception e) { } catch (Exception e) {
logError("JSON parsing error: ", e); logError("JSON parsing error: ", e);
showNoLocationFragment(getActivity()); showNoLocationFragment(getActivity());
@ -398,6 +401,7 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
@Override @Override
public void updateLocation(final Location loc) { public void updateLocation(final Location loc) {
final OsmandApplication app = getMyApplication(); final OsmandApplication app = getMyApplication();
if (loc != null) {
app.runInUIThread(new Runnable() { app.runInUIThread(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -410,6 +414,7 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
} }
}); });
} }
}
@Override @Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) { public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {