GUI refresh amendments

This commit is contained in:
Philip Abbey
2024-01-09 08:58:58 +00:00
parent 9858ebbe73
commit 864a832e69
3 changed files with 13 additions and 6 deletions

View File

@ -196,9 +196,11 @@ class HomeAssistantApp extends Application.AppBase {
break; break;
case 200: case 200:
mMenuStatus = RezStrings.getAvailable();
if (Settings.getCacheConfig()) { if (Settings.getCacheConfig()) {
Storage.setValue("menu", data as Lang.Dictionary); Storage.setValue("menu", data as Lang.Dictionary);
mMenuStatus = RezStrings.getCached();
} else {
mMenuStatus = RezStrings.getAvailable();
} }
if (!mIsGlance) { if (!mIsGlance) {
buildMenu(data); buildMenu(data);
@ -268,6 +270,7 @@ class HomeAssistantApp extends Application.AppBase {
} }
} else { } else {
mMenuStatus = RezStrings.getCached(); mMenuStatus = RezStrings.getCached();
WatchUi.requestUpdate();
if (!mIsGlance) { if (!mIsGlance) {
buildMenu(menu); buildMenu(menu);
} }
@ -467,15 +470,15 @@ class HomeAssistantApp extends Application.AppBase {
RezStrings.update_glance(); RezStrings.update_glance();
mApiStatus = RezStrings.getChecking(); mApiStatus = RezStrings.getChecking();
mMenuStatus = RezStrings.getChecking(); mMenuStatus = RezStrings.getChecking();
updateGlance(); updateStatus();
Settings.update(); Settings.update();
mTimer = new Timer.Timer(); mTimer = new Timer.Timer();
mTimer.start(method(:updateGlance), Globals.scApiBackoff, true); mTimer.start(method(:updateStatus), Globals.scApiBackoff, true);
return [new HomeAssistantGlanceView(self)]; return [new HomeAssistantGlanceView(self)];
} }
// Required for the Glance update timer. // Required for the Glance update timer.
function updateGlance() as Void { function updateStatus() as Void {
fetchMenuConfig(); fetchMenuConfig();
fetchApiStatus(); fetchApiStatus();
} }

View File

@ -104,12 +104,12 @@ class HomeAssistantView extends WatchUi.Menu2 {
// //
class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate { class HomeAssistantViewDelegate extends WatchUi.Menu2InputDelegate {
private var mIsRootMenuView as Lang.Boolean = false; private var mIsRootMenuView as Lang.Boolean = false;
private var mTimer as QuitTimer; private var mTimer as QuitTimer;
function initialize(isRootMenuView as Lang.Boolean) { function initialize(isRootMenuView as Lang.Boolean) {
Menu2InputDelegate.initialize(); Menu2InputDelegate.initialize();
mIsRootMenuView = isRootMenuView; mIsRootMenuView = isRootMenuView;
mTimer = getApp().getQuitTimer(); mTimer = getApp().getQuitTimer();
} }
function onBack() { function onBack() {

View File

@ -115,6 +115,10 @@ class RootView extends ScalableView {
mMenuStatus.setText(mApp.getMenuStatus()); mMenuStatus.setText(mApp.getMenuStatus());
mMenuStatus.draw(dc); mMenuStatus.draw(dc);
} }
function onShow() as Void {
WatchUi.requestUpdate();
}
} }
class RootViewDelegate extends WatchUi.BehaviorDelegate { class RootViewDelegate extends WatchUi.BehaviorDelegate {