Fix GeoIntentActivity crash

This commit is contained in:
Alexey Kulish 2017-05-30 12:49:10 +03:00
parent d75ecfa084
commit c61ff3bbf8

View file

@ -7,17 +7,8 @@ import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.widget.Toast;
import net.osmand.ResultMatcher;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.City;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.MapObject; import net.osmand.data.MapObject;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -31,20 +22,9 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.OsmandListActivity; import net.osmand.plus.activities.OsmandListActivity;
import net.osmand.plus.resources.RegionAddressRepository;
import net.osmand.plus.resources.ResourceManager;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.GeoPointParserUtil; import net.osmand.util.GeoPointParserUtil;
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint; import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
import net.osmand.util.MapUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import gnu.trove.map.hash.TLongObjectHashMap;
public class GeoIntentActivity extends OsmandListActivity { public class GeoIntentActivity extends OsmandListActivity {
@ -141,21 +121,31 @@ public class GeoIntentActivity extends OsmandListActivity {
@Override @Override
protected void onPostExecute(GeoPointParserUtil.GeoParsedPoint p ) { protected void onPostExecute(GeoPointParserUtil.GeoParsedPoint p ) {
progress.dismiss(); if (progress != null && progress.isShowing()) {
OsmandSettings settings = getMyApplication().getSettings(); try {
if (p != null && p.isGeoPoint()) { progress.dismiss();
PointDescription pd = new PointDescription(p.getLatitude(), p.getLongitude()); } catch (Exception e) {
if(!Algorithms.isEmpty(p.getLabel())) { e.printStackTrace();
pd.setName(p.getLabel());
} }
settings.setMapLocationToShow(p.getLatitude(), p.getLongitude(),
settings.getLastKnownMapZoom(), pd); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this);
} }
Uri uri = intent.getData(); try {
String searchString = p != null && p.isGeoAddress() ? p.getQuery() : uri.toString(); OsmandSettings settings = getMyApplication().getSettings();
settings.setSearchRequestToShow(searchString); if (p != null && p.isGeoPoint()) {
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this); PointDescription pd = new PointDescription(p.getLatitude(), p.getLongitude());
if (!Algorithms.isEmpty(p.getLabel())) {
pd.setName(p.getLabel());
}
settings.setMapLocationToShow(p.getLatitude(), p.getLongitude(),
settings.getLastKnownMapZoom(), pd); //$NON-NLS-1$
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this);
}
Uri uri = intent.getData();
String searchString = p != null && p.isGeoAddress() ? p.getQuery() : uri.toString();
settings.setSearchRequestToShow(searchString);
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this);
} catch (Exception e) {
e.printStackTrace();
}
} }
} }