mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-04-30 20:52:27 +00:00
Menu item code tidy
Prior to sorting out inheritance.
This commit is contained in:
@ -47,6 +47,10 @@ class HomeAssistantGroupMenuItem extends WatchUi.IconMenuItem {
|
||||
mMenu = new HomeAssistantView(definition, null);
|
||||
}
|
||||
|
||||
function hasTemplate() as Lang.Boolean {
|
||||
return mTemplate != null;
|
||||
}
|
||||
|
||||
function buildTemplate() as Lang.String or Null {
|
||||
return mTemplate;
|
||||
}
|
||||
@ -63,7 +67,7 @@ class HomeAssistantGroupMenuItem extends WatchUi.IconMenuItem {
|
||||
var f = data as Lang.Float;
|
||||
setSubLabel(f.format("%f"));
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantGroupMenuItem updateState() data = " + data);
|
||||
// System.println("HomeAssistantGroupMenuItem updateState() data = " + data);
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
} else {
|
||||
@ -80,8 +84,4 @@ class HomeAssistantGroupMenuItem extends WatchUi.IconMenuItem {
|
||||
return mMenu;
|
||||
}
|
||||
|
||||
function hasTemplate() as Lang.Boolean {
|
||||
return mTemplate != null;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class HomeAssistantTapMenuItem extends WatchUi.IconMenuItem {
|
||||
var f = data as Lang.Float;
|
||||
setSubLabel(f.format("%f"));
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantTemplateMenuItem updateState() data = " + data);
|
||||
// System.println("HomeAssistantTapMenuItem updateState() data = " + data);
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
} else {
|
||||
|
@ -42,7 +42,13 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
:icon as Graphics.BitmapType or WatchUi.Drawable or Lang.Symbol
|
||||
} or Null
|
||||
) {
|
||||
WatchUi.ToggleMenuItem.initialize(label, null, null, false, options);
|
||||
WatchUi.ToggleMenuItem.initialize(
|
||||
label,
|
||||
null,
|
||||
null,
|
||||
false,
|
||||
options
|
||||
);
|
||||
if (Attention has :vibrate) {
|
||||
mHasVibrate = true;
|
||||
}
|
||||
@ -81,7 +87,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
var f = data as Lang.Float;
|
||||
setSubLabel(f.format("%f"));
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantToggleMenuItem updateState() data = " + data);
|
||||
// System.println("HomeAssistantToggleMenuItem updateState() data = " + data);
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
} else {
|
||||
@ -93,6 +99,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
}
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
function updateToggleState(data as Lang.String or Lang.Dictionary or Null) as Void {
|
||||
if (data == null) {
|
||||
setUiToggle("off");
|
||||
@ -102,7 +109,7 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
||||
setSubLabel($.Rez.Strings.Unavailable);
|
||||
}
|
||||
} else if(data instanceof Lang.Dictionary) {
|
||||
// System.println("HomeAsistantToggleMenuItem updateState() data = " + data);
|
||||
// System.println("HomeAssistantToggleMenuItem updateState() data = " + data);
|
||||
if (mTemplate == null) {
|
||||
if (data.get("error") != null) {
|
||||
setSubLabel($.Rez.Strings.TemplateError);
|
||||
|
Reference in New Issue
Block a user