From 9414f57ab9a48575770647795048f110b8bed6cd Mon Sep 17 00:00:00 2001 From: Alexey Kulish Date: Mon, 8 Aug 2016 20:35:49 +0300 Subject: [PATCH] [Quick search] fix show on map crash with no selected word --- OsmAnd/src/net/osmand/plus/activities/MapActivity.java | 8 ++++++-- .../net/osmand/plus/search/QuickSearchDialogFragment.java | 7 ++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java index cff54076d1..97794a69ab 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivity.java @@ -1374,7 +1374,11 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven } public void showQuickSearch(ShowQuickSearchMode mode, boolean showCategories) { - mapContextMenu.hide(); + if (mapContextMenu.isVisible()) { + mapContextMenu.hide(); + } else if (mapContextMenu.getMultiSelectionMenu().isVisible()) { + mapContextMenu.getMultiSelectionMenu().hide(); + } QuickSearchDialogFragment fragment = getQuickSearchDialogFragment(); if (fragment != null) { if (mode == ShowQuickSearchMode.NEW || (mode == ShowQuickSearchMode.NEW_IF_EXPIRED && fragment.isExpired())) { @@ -1419,7 +1423,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven this.topToolbarActive = mapInfoLayer.hasTopToolbar(); } - public static enum ShowQuickSearchMode { + public enum ShowQuickSearchMode { NEW, NEW_IF_EXPIRED, CURRENT, diff --git a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java index ffffbbad3d..5e5a35280f 100644 --- a/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/search/QuickSearchDialogFragment.java @@ -197,7 +197,12 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC QuickSearchCoordinatesFragment.showDialog(QuickSearchDialogFragment.this, searchPhrase.getUnknownSearchWord()); } else if (searchPhrase.isNoSelectedType() || searchPhrase.isLastWord(ObjectType.POI_TYPE)) { PoiUIFilter filter; - if (searchPhrase.getLastSelectedWord().getResult().object instanceof AbstractPoiType) { + if (searchPhrase.isNoSelectedType()) { + filter = new PoiUIFilter(null, app, ""); + if (!Algorithms.isEmpty(searchPhrase.getUnknownSearchWord())) { + filter.setFilterByName(searchPhrase.getUnknownSearchWord()); + } + } else if (searchPhrase.getLastSelectedWord().getResult().object instanceof AbstractPoiType) { if (searchPhrase.isNoSelectedType()) { filter = new PoiUIFilter(null, app, ""); } else {