From 73778122cbacf6b813489442829c38e319af0582 Mon Sep 17 00:00:00 2001 From: crimean Date: Mon, 4 Mar 2019 12:16:08 +0300 Subject: [PATCH] Fix crash --- .../routepreparationmenu/cards/HistoryCard.java | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java index b70c21c501..f395911bcf 100644 --- a/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java +++ b/OsmAnd/src/net/osmand/plus/routepreparationmenu/cards/HistoryCard.java @@ -13,6 +13,7 @@ import net.osmand.AndroidUtils; import net.osmand.data.PointDescription; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; +import net.osmand.plus.activities.search.SearchHistoryFragment; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.search.core.SearchResult; @@ -71,11 +72,15 @@ public class HistoryCard extends BaseCard { } else { subtitleView.setVisibility(View.GONE); } - Drawable image = null; - int iconId = QuickSearchListItem.getHistoryIconId(app, (HistoryEntry) searchResult.object); - if (iconId > 0) { + Drawable image; + final HistoryEntry entry = (HistoryEntry) searchResult.object; + int iconId = QuickSearchListItem.getHistoryIconId(app, entry); + try { image = app.getUIUtilities().getIcon(iconId, nightMode ? R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light); + } catch (Exception e) { + image = app.getUIUtilities().getIcon(SearchHistoryFragment.getItemIcon(entry.getName()), nightMode ? + R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light); } ImageView img = (ImageView) v.findViewById(R.id.imageView); img.setImageDrawable(image); @@ -93,8 +98,7 @@ public class HistoryCard extends BaseCard { v.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - HistoryEntry historyEntry = (HistoryEntry) searchResult.object; - app.getTargetPointsHelper().navigateToPoint(searchResult.location, true, -1, historyEntry.getName()); + app.getTargetPointsHelper().navigateToPoint(searchResult.location, true, -1, entry.getName()); } }); items.addView(v);