Added cache vars to aidl widget
This commit is contained in:
parent
a0e380b5ce
commit
3217aae9a3
1 changed files with 26 additions and 6 deletions
|
@ -184,6 +184,13 @@ public class ConnectedApp implements Comparable<ConnectedApp> {
|
|||
|
||||
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,6 +199,14 @@ public class ConnectedApp implements Comparable<ConnectedApp> {
|
|||
String subtext = widget.getDescription();
|
||||
boolean night = drawSettings != null && drawSettings.isNightMode();
|
||||
int icon = AndroidUtils.getDrawableId(mapActivity.getMyApplication(), night ? widget.getDarkIconName() : widget.getLightIconName());
|
||||
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);
|
||||
|
@ -201,6 +216,11 @@ public class ConnectedApp implements Comparable<ConnectedApp> {
|
|||
return true;
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
setText(null, null);
|
||||
setImageDrawable(null);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
};
|
||||
control.updateInfo(null);
|
||||
|
|
Loading…
Reference in a new issue