Add error handling for empty menu data

New string resource for menu definition errors and updates HomeAssistantApp to show an error message when the menu data is empty.
This commit is contained in:
Philip Abbey
2025-12-13 16:29:18 +00:00
parent fd373e9dbb
commit 66bae3ac57
2 changed files with 3 additions and 0 deletions

View File

@@ -32,6 +32,7 @@
<string id="NoConfigUrl" scope="glance">No configuration URL in the application settings.</string>
<string id="NoInternet">No Internet connection.</string>
<string id="NoJson">No JSON returned from HTTP request.</string>
<string id="NoMenu">Menu definition error, check the instructions.</string>
<string id="NoPhone" scope="glance">No Phone connection.</string>
<string id="NoPhoneNoCache" scope="glance">No phone connection, no cached menu.</string>
<string id="NoResponse">No Response, check Internet connection</string>

View File

@@ -218,6 +218,8 @@ class HomeAssistantApp extends Application.AppBase {
} else {
if (data == null) {
ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoJson) as Lang.String);
} else if (data.size() == 0) {
ErrorView.show(WatchUi.loadResource($.Rez.Strings.NoMenu) as Lang.String);
} else {
buildMenu(data);
WatchUi.switchToView(mHaMenu, new HomeAssistantViewDelegate(false), WatchUi.SLIDE_IMMEDIATE);