diff --git a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java index b207bd853c..74166b9ec9 100644 --- a/OsmAnd/src/net/osmand/aidl/ConnectedApp.java +++ b/OsmAnd/src/net/osmand/aidl/ConnectedApp.java @@ -184,6 +184,13 @@ public class ConnectedApp implements Comparable { TextInfoWidget createWidgetControl(final MapActivity mapActivity, final String widgetId) { TextInfoWidget control = new TextInfoWidget(mapActivity) { + + private boolean init = true; + private String cachedTxt; + private String cachedSubtext; + private Boolean cachedNight; + private Integer cachedIcon; + @Override public boolean updateInfo(OsmandMapLayer.DrawSettings drawSettings) { AidlMapWidgetWrapper widget = widgets.get(widgetId); @@ -192,15 +199,28 @@ public class ConnectedApp implements Comparable { String subtext = widget.getDescription(); boolean night = drawSettings != null && drawSettings.isNightMode(); int icon = AndroidUtils.getDrawableId(mapActivity.getMyApplication(), night ? widget.getDarkIconName() : widget.getLightIconName()); - setText(txt, subtext); - if (icon != 0) { - setImageDrawable(icon); - } else { - setImageDrawable(null); + if (init || !Algorithms.objectEquals(txt, cachedTxt) || !Algorithms.objectEquals(subtext, cachedSubtext) + || !Algorithms.objectEquals(night, cachedNight) || !Algorithms.objectEquals(icon, cachedIcon)) { + init = false; + cachedTxt = txt; + cachedSubtext = subtext; + cachedNight = night; + cachedIcon = icon; + + setText(txt, subtext); + if (icon != 0) { + setImageDrawable(icon); + } else { + setImageDrawable(null); + } + return true; } + return false; + } else { + setText(null, null); + setImageDrawable(null); return true; } - return false; } }; control.updateInfo(null);