From c61ff3bbf8f5caea6fc5d62b12d27221658b4fe5 Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Tue, 30 May 2017 12:49:10 +0300 Subject: [PATCH] Fix GeoIntentActivity crash --- .../activities/search/GeoIntentActivity.java | 58 ++++++++----------- 1 file changed, 24 insertions(+), 34 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java index ef10e312c2..7ffeae8397 100644 --- a/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/search/GeoIntentActivity.java @@ -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,21 +121,31 @@ public class GeoIntentActivity extends OsmandListActivity { @Override protected void onPostExecute(GeoPointParserUtil.GeoParsedPoint p ) { - progress.dismiss(); - OsmandSettings settings = getMyApplication().getSettings(); - if (p != null && p.isGeoPoint()) { - PointDescription pd = new PointDescription(p.getLatitude(), p.getLongitude()); - if(!Algorithms.isEmpty(p.getLabel())) { - pd.setName(p.getLabel()); + if (progress != null && progress.isShowing()) { + try { + progress.dismiss(); + } catch (Exception e) { + e.printStackTrace(); } - 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); + try { + OsmandSettings settings = getMyApplication().getSettings(); + if (p != null && p.isGeoPoint()) { + 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(); + } } }