From ff5b795694c10ef0a228ac07eaa7fbf382cd5fba Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Tue, 22 May 2018 23:57:39 +0200 Subject: [PATCH] Fix crashes --- .../plus/mapillary/MapillaryPlugin.java | 21 +++++++++++-------- .../search/QuickSearchDialogFragment.java | 2 +- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java index c8b93ecad4..c1547333b2 100644 --- a/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java +++ b/OsmAnd/src/net/osmand/plus/mapillary/MapillaryPlugin.java @@ -13,7 +13,6 @@ import android.view.View; import android.view.ViewGroup; import android.widget.ArrayAdapter; import android.widget.CompoundButton; - import net.osmand.AndroidUtils; import net.osmand.map.ITileSource; import net.osmand.map.TileSourceManager; @@ -230,14 +229,18 @@ public class MapillaryPlugin extends OsmandPlugin { boolean success = false; OsmandApplication app = (OsmandApplication) activity.getApplication(); if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) { - if (imageKey != null) { - Intent intent = new Intent(ACTION_VIEW, Uri.parse(MessageFormat.format("mapillary://mapillary/photo/{0}?image_key={0}", imageKey))); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - app.startActivity(intent); - } else { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mapillary://mapillary/capture")); - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); - app.startActivity(intent); + try { + if (imageKey != null) { + Intent intent = new Intent(ACTION_VIEW, Uri.parse(MessageFormat.format("mapillary://mapillary/photo/{0}?image_key={0}", imageKey))); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + app.startActivity(intent); + } else { + Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mapillary://mapillary/capture")); + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + app.startActivity(intent); + } + } catch (ActivityNotFoundException e) { + new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG); } success = true; } else { diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index 1cbb0f1919..d363aeded7 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -769,7 +769,7 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC if (dialog == null) { return; } - if (useMapCenter) { + if (useMapCenter && getMapActivity() != null) { LatLon mapCenter = getMapActivity().getMapView().getCurrentRotatedTileBox().getCenterLatLon(); SearchSettings ss = searchUICore.getSearchSettings().setOriginalLocation( new LatLon(mapCenter.getLatitude(), mapCenter.getLongitude()));