Skip to content

Commit

Permalink
launch - Set a remove method for the scroller
Browse files Browse the repository at this point in the history
  • Loading branch information
halemmerich committed Oct 28, 2022
1 parent 4c761cd commit 74d0499
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions apps/launch/app.js
Expand Up @@ -41,6 +41,16 @@ let apps = launchCache.apps;
// Now apps list is loaded - render
if (!settings.fullscreen)
Bangle.loadWidgets();

let btnWatch;

let cleanup = function() {
// unload everything manually
if (btnWatch) clearWatch(btnWatch);
if (lockTimeout) clearTimeout(lockTimeout);
Bangle.removeListener("lock", lockHandler);
};

E.showScroller({
h : 64*scaleval, c : apps.length,
draw : (i, r) => {
Expand All @@ -62,22 +72,19 @@ E.showScroller({
} else {
load(app.src);
}
}
},
remove: cleanup
});
g.flip(); // force a render before widgets have finished drawing

let returnToClock = function() {
// unload everything manually
if (lockTimeout) clearTimeout(lockTimeout);
Bangle.removeListener("lock", lockHandler);
// now load the default clock
Bangle.showClock();
}

};
// on bangle.js 2, the screen is used for navigating, so the single button goes back
// on bangle.js 1, the buttons are used for navigating
if (process.env.HWVERSION==2) {
setWatch(returnToClock, BTN1, {edge:"falling"});
btnWatch = setWatch(returnToClock, BTN1, {edge:"falling"});
}

// 10s of inactivity goes back to clock
Expand All @@ -88,7 +95,7 @@ let lockHandler = function(locked) {
lockTimeout = undefined;
if (locked)
lockTimeout = setTimeout(returnToClock, 10000);
}
};
Bangle.on("lock", lockHandler);
if (!settings.fullscreen) // finally draw widgets
Bangle.drawWidgets();
Expand Down

0 comments on commit 74d0499

Please sign in to comment.