Fix crash

This commit is contained in:
crimean 2019-03-04 12:16:08 +03:00
parent 6e56316c70
commit 73778122cb

View file

@ -13,6 +13,7 @@ import net.osmand.AndroidUtils;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.activities.search.SearchHistoryFragment;
import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry; import net.osmand.plus.helpers.SearchHistoryHelper.HistoryEntry;
import net.osmand.plus.search.listitems.QuickSearchListItem; import net.osmand.plus.search.listitems.QuickSearchListItem;
import net.osmand.search.core.SearchResult; import net.osmand.search.core.SearchResult;
@ -71,11 +72,15 @@ public class HistoryCard extends BaseCard {
} else { } else {
subtitleView.setVisibility(View.GONE); subtitleView.setVisibility(View.GONE);
} }
Drawable image = null; Drawable image;
int iconId = QuickSearchListItem.getHistoryIconId(app, (HistoryEntry) searchResult.object); final HistoryEntry entry = (HistoryEntry) searchResult.object;
if (iconId > 0) { int iconId = QuickSearchListItem.getHistoryIconId(app, entry);
try {
image = app.getUIUtilities().getIcon(iconId, nightMode ? image = app.getUIUtilities().getIcon(iconId, nightMode ?
R.color.route_info_control_icon_color_dark : R.color.route_info_control_icon_color_light); 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); ImageView img = (ImageView) v.findViewById(R.id.imageView);
img.setImageDrawable(image); img.setImageDrawable(image);
@ -93,8 +98,7 @@ public class HistoryCard extends BaseCard {
v.setOnClickListener(new View.OnClickListener() { v.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
HistoryEntry historyEntry = (HistoryEntry) searchResult.object; app.getTargetPointsHelper().navigateToPoint(searchResult.location, true, -1, entry.getName());
app.getTargetPointsHelper().navigateToPoint(searchResult.location, true, -1, historyEntry.getName());
} }
}); });
items.addView(v); items.addView(v);