mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-07-14 00:38:32 +00:00
Review comment
Moved point of application exit for the menu item option.
This commit is contained in:
@ -46,7 +46,13 @@ class HomeAssistantService {
|
|||||||
data as Null or Lang.Dictionary or Lang.String,
|
data as Null or Lang.Dictionary or Lang.String,
|
||||||
context as Lang.Object
|
context as Lang.Object
|
||||||
) as Void {
|
) as Void {
|
||||||
var entity_id = context as Lang.String or Null;
|
var c = context as Lang.Dictionary;
|
||||||
|
var entity_id;
|
||||||
|
var exit = false;
|
||||||
|
if (c != null) {
|
||||||
|
entity_id = c.get(:entity_id) as Lang.String;
|
||||||
|
exit = c.get(:exit) as Lang.Boolean;
|
||||||
|
}
|
||||||
// System.println("HomeAssistantService onReturnCall() Response Code: " + responseCode);
|
// System.println("HomeAssistantService onReturnCall() Response Code: " + responseCode);
|
||||||
// System.println("HomeAssistantService onReturnCall() Response Data: " + data);
|
// System.println("HomeAssistantService onReturnCall() Response Data: " + data);
|
||||||
|
|
||||||
@ -102,6 +108,9 @@ class HomeAssistantService {
|
|||||||
:bgcolor => Graphics.COLOR_BLACK
|
:bgcolor => Graphics.COLOR_BLACK
|
||||||
}).pushView(WatchUi.SLIDE_IMMEDIATE);
|
}).pushView(WatchUi.SLIDE_IMMEDIATE);
|
||||||
}
|
}
|
||||||
|
if (exit) {
|
||||||
|
System.exit();
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -117,7 +126,8 @@ class HomeAssistantService {
|
|||||||
//
|
//
|
||||||
function call(
|
function call(
|
||||||
service as Lang.String,
|
service as Lang.String,
|
||||||
data as Lang.Dictionary or Null
|
data as Lang.Dictionary or Null,
|
||||||
|
exit as Lang.Boolean
|
||||||
) as Void {
|
) as Void {
|
||||||
if (! System.getDeviceSettings().phoneConnected) {
|
if (! System.getDeviceSettings().phoneConnected) {
|
||||||
// System.println("HomeAssistantService call(): No Phone connection, skipping API call.");
|
// System.println("HomeAssistantService call(): No Phone connection, skipping API call.");
|
||||||
@ -149,7 +159,10 @@ class HomeAssistantService {
|
|||||||
"Authorization" => "Bearer " + Settings.getApiKey()
|
"Authorization" => "Bearer " + Settings.getApiKey()
|
||||||
},
|
},
|
||||||
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON,
|
:responseType => Communications.HTTP_RESPONSE_CONTENT_TYPE_JSON,
|
||||||
:context => entity_id
|
:context => {
|
||||||
|
:entity_id => entity_id,
|
||||||
|
:exit => exit
|
||||||
|
}
|
||||||
},
|
},
|
||||||
method(:onReturnCall)
|
method(:onReturnCall)
|
||||||
);
|
);
|
||||||
|
@ -106,10 +106,7 @@ class HomeAssistantTapMenuItem extends HomeAssistantMenuItem {
|
|||||||
//
|
//
|
||||||
function onConfirm(b as Lang.Boolean) as Void {
|
function onConfirm(b as Lang.Boolean) as Void {
|
||||||
if (mService != null) {
|
if (mService != null) {
|
||||||
mHomeAssistantService.call(mService, mData);
|
mHomeAssistantService.call(mService, mData, mExit);
|
||||||
}
|
|
||||||
if (mExit) {
|
|
||||||
System.exit();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,6 +215,9 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
|||||||
ErrorView.show(WatchUi.loadResource($.Rez.Strings.UnhandledHttpErr) as Lang.String + responseCode);
|
ErrorView.show(WatchUi.loadResource($.Rez.Strings.UnhandledHttpErr) as Lang.String + responseCode);
|
||||||
}
|
}
|
||||||
getApp().setApiStatus(status);
|
getApp().setApiStatus(status);
|
||||||
|
if (mExit) {
|
||||||
|
System.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Set the state of the toggle menu item.
|
//! Set the state of the toggle menu item.
|
||||||
@ -297,9 +300,6 @@ class HomeAssistantToggleMenuItem extends WatchUi.ToggleMenuItem {
|
|||||||
//
|
//
|
||||||
function onConfirm(b as Lang.Boolean) as Void {
|
function onConfirm(b as Lang.Boolean) as Void {
|
||||||
setState(b);
|
setState(b);
|
||||||
if (mExit) {
|
|
||||||
System.exit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user