import Toybox.Graphics; import Toybox.Lang; import Toybox.WatchUi; (:glance) class WidgetGlanceView extends WatchUi.GlanceView { public function initialize() { log("g.initialize"); GlanceView.initialize(); } public function onLayout(dc as Dc) as Void { log("g.onLayout"); } public function onShow() as Void { log("g.onShow"); } public function onHide() as Void { log("g.onHide"); } public function onUpdate(dc as Dc) as Void { log("g.onUpdate"); var text = formatTimestamp(TIME_FORMAT, null); var width = dc.getWidth(); var height = dc.getHeight(); var font = Graphics.FONT_XTINY; var justification = Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER; dc.setColor(Graphics.COLOR_WHITE, Graphics.COLOR_BLACK); dc.clear(); dc.drawText(width/2, height/2, font, text, justification); } function formatTimestamp(format as String, ts as Number?) as String { var m = ts != null ? new Time.Moment(ts) : Time.now(); var t = Time.Gregorian.info(m, Time.FORMAT_SHORT); return Lang.format( format, [ (t.month as Number).format("%02d"), // depends on FORMAT_SHORT t.day, t.hour.format("%02d"), t.min.format("%02d"), t.sec.format("%02d"), ]); } }
With the above code for my glance I see the following in the log when I run it in simulator on SDK 4.1.4 (fenix6 but also others):
so there's a 29 seconds lag between initialize and onLayout. Anybody knows why?