From d33abf0f035ed1d3a2f170eee38c2a9daf31f987 Mon Sep 17 00:00:00 2001 From: Vitaliy Date: Fri, 24 Jan 2020 18:16:45 +0200 Subject: [PATCH] Add check for icon res name --- OsmAnd/src/net/osmand/plus/ApplicationMode.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/ApplicationMode.java b/OsmAnd/src/net/osmand/plus/ApplicationMode.java index fadef77988..8f5429ad1c 100644 --- a/OsmAnd/src/net/osmand/plus/ApplicationMode.java +++ b/OsmAnd/src/net/osmand/plus/ApplicationMode.java @@ -254,9 +254,13 @@ public class ApplicationMode { public ApplicationModeBuilder icon(Context app, String iconResName) { try { - applicationMode.iconResName = iconResName; - applicationMode.iconMapRes = applicationMode.iconRes = app.getResources().getIdentifier(iconResName, "drawable", app.getPackageName()); - applicationMode.iconMapRes = app.getResources().getIdentifier(iconResName.replace("ic_", "map_"), "drawable", app.getPackageName()); + int iconRes = app.getResources().getIdentifier(iconResName, "drawable", app.getPackageName()); + int iconMapRes = app.getResources().getIdentifier(iconResName.replace("ic_", "map_"), "drawable", app.getPackageName()); + if (iconRes != 0 && iconMapRes != 0) { + applicationMode.iconResName = iconResName; + applicationMode.iconRes = iconRes; + applicationMode.iconMapRes = iconMapRes; + } } catch (Exception e) { // return R.drawable.map_world_globe_dark; }