mirror of
https://github.com/house-of-abbey/GarminHomeAssistant.git
synced 2025-06-18 12:28:41 +00:00
Update HomeAssistantApp.mc (#152)
When Settings.getPollDelay() > 0, do not wait for this time before the initial batch of updates, so the app is more responsive on opening.
This commit is contained in:
@ -38,6 +38,7 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
private var mNextItemToUpdate as Lang.Number = 0; // Index into the above array
|
private var mNextItemToUpdate as Lang.Number = 0; // Index into the above array
|
||||||
private var mIsGlance as Lang.Boolean = false;
|
private var mIsGlance as Lang.Boolean = false;
|
||||||
private var mIsApp as Lang.Boolean = false; // Or Widget
|
private var mIsApp as Lang.Boolean = false; // Or Widget
|
||||||
|
private var mIsInitUpdateCompl as Lang.Boolean = false;
|
||||||
|
|
||||||
function initialize() {
|
function initialize() {
|
||||||
AppBase.initialize();
|
AppBase.initialize();
|
||||||
@ -400,7 +401,7 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
|
|
||||||
function updateNextMenuItem() as Void {
|
function updateNextMenuItem() as Void {
|
||||||
var delay = Settings.getPollDelay();
|
var delay = Settings.getPollDelay();
|
||||||
if ((delay > 0) and (mNextItemToUpdate == 0)) {
|
if (mIsInitUpdateCompl and (delay > 0) and (mNextItemToUpdate == 0)) {
|
||||||
mUpdateTimer.start(method(:updateNextMenuItemInternal), delay, false);
|
mUpdateTimer.start(method(:updateNextMenuItemInternal), delay, false);
|
||||||
} else {
|
} else {
|
||||||
updateNextMenuItemInternal();
|
updateNextMenuItemInternal();
|
||||||
@ -412,8 +413,16 @@ class HomeAssistantApp extends Application.AppBase {
|
|||||||
function updateNextMenuItemInternal() as Void {
|
function updateNextMenuItemInternal() as Void {
|
||||||
var itu = mItemsToUpdate as Lang.Array<HomeAssistantToggleMenuItem>;
|
var itu = mItemsToUpdate as Lang.Array<HomeAssistantToggleMenuItem>;
|
||||||
if (itu != null) {
|
if (itu != null) {
|
||||||
|
// System.println("HomeAssistantApp updateNextMenuItemInternal(): Doing update for item " + mNextItemToUpdate + ", mIsInitUpdateCompl=" + mIsInitUpdateCompl);
|
||||||
itu[mNextItemToUpdate].getState();
|
itu[mNextItemToUpdate].getState();
|
||||||
mNextItemToUpdate = (mNextItemToUpdate + 1) % itu.size();
|
// mNextItemToUpdate = (mNextItemToUpdate + 1) % itu.size() - But with roll-over detection
|
||||||
|
if (mNextItemToUpdate == itu.size()-1) {
|
||||||
|
// Last item completed return to the start of the list
|
||||||
|
mNextItemToUpdate = 0;
|
||||||
|
mIsInitUpdateCompl = true;
|
||||||
|
} else {
|
||||||
|
mNextItemToUpdate++;
|
||||||
|
}
|
||||||
// } else {
|
// } else {
|
||||||
// System.println("HomeAssistantApp updateNextMenuItemInternal(): No menu items to update");
|
// System.println("HomeAssistantApp updateNextMenuItemInternal(): No menu items to update");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user