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.os.AsyncTask;
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.City;
import net.osmand.data.LatLon;
import net.osmand.data.MapObject;
import net.osmand.data.PointDescription;
@ -31,20 +22,9 @@ import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity;
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.GeoPointParserUtil;
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 {
@ -141,11 +121,18 @@ public class GeoIntentActivity extends OsmandListActivity {
@Override
protected void onPostExecute(GeoPointParserUtil.GeoParsedPoint p ) {
if (progress != null && progress.isShowing()) {
try {
progress.dismiss();
} catch (Exception e) {
e.printStackTrace();
}
}
try {
OsmandSettings settings = getMyApplication().getSettings();
if (p != null && p.isGeoPoint()) {
PointDescription pd = new PointDescription(p.getLatitude(), p.getLongitude());
if(!Algorithms.isEmpty(p.getLabel())) {
if (!Algorithms.isEmpty(p.getLabel())) {
pd.setName(p.getLabel());
}
settings.setMapLocationToShow(p.getLatitude(), p.getLongitude(),
@ -156,6 +143,9 @@ public class GeoIntentActivity extends OsmandListActivity {
String searchString = p != null && p.isGeoAddress() ? p.getQuery() : uri.toString();
settings.setSearchRequestToShow(searchString);
MapActivity.launchMapActivityMoveToTop(GeoIntentActivity.this);
} catch (Exception e) {
e.printStackTrace();
}
}
}