mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-08-13 15:18:31 +00:00
Single request to update
This commit is contained in:
@ -26,8 +26,9 @@ using Toybox.Lang;
|
||||
using Toybox.WatchUi;
|
||||
using Toybox.Graphics;
|
||||
|
||||
class HomeAssistantTemplateMenuItem extends TemplateMenuItem {
|
||||
class HomeAssistantTemplateMenuItem extends WatchUi.IconMenuItem {
|
||||
private var mHomeAssistantService as HomeAssistantService;
|
||||
private var mTemplate as Lang.String;
|
||||
private var mService as Lang.String or Null;
|
||||
private var mConfirm as Lang.Boolean;
|
||||
private var mData as Lang.Dictionary or Null;
|
||||
@ -44,21 +45,30 @@ class HomeAssistantTemplateMenuItem extends TemplateMenuItem {
|
||||
} or Null,
|
||||
haService as HomeAssistantService
|
||||
) {
|
||||
TemplateMenuItem.initialize(
|
||||
WatchUi.IconMenuItem.initialize(
|
||||
label,
|
||||
template,
|
||||
// Now this feels very "closely coupled" to the application, but it is the most reliable method instead of using a timer.
|
||||
getApp().method(:updateNextMenuItem),
|
||||
null,
|
||||
null,
|
||||
icon,
|
||||
options
|
||||
);
|
||||
|
||||
mHomeAssistantService = haService;
|
||||
mTemplate = template;
|
||||
mService = service;
|
||||
mConfirm = confirm;
|
||||
mData = data;
|
||||
}
|
||||
|
||||
function buildTemplate() as Lang.String or Null {
|
||||
return mTemplate;
|
||||
}
|
||||
|
||||
function updateState(data as Lang.String or Null) as Void {
|
||||
setSubLabel(data);
|
||||
WatchUi.requestUpdate();
|
||||
}
|
||||
|
||||
function callService() as Void {
|
||||
if (mConfirm) {
|
||||
WatchUi.pushView(
|
||||
|
Reference in New Issue
Block a user