[Quick search] fix show on map crash with no selected word

This commit is contained in:
Alexey Kulish 2016-08-08 20:35:49 +03:00
parent b603812edd
commit 9414f57ab9
2 changed files with 12 additions and 3 deletions

View file

@ -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,

View file

@ -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 {