Started a new widget. I get a strange error when onUpdate is triggered by WatchUi.requestUpdate() from a timer:
Error: Symbol Not Found Error
Details: Failed invoking <symbol>
Stack:
Encountered app crash.
There's no stack trace, so the only way I could find out where it happens was in debugger. It's on dc.drawText:
import Toybox.Graphics;
import Toybox.Lang;
import Toybox.Timer;
import Toybox.WatchUi;
(:glance)
class FooGlanceView extends WatchUi.GlanceView {
private var mTimer as Timer.Timer?;
public function onShow() as Void {
mTimer = new Timer.Timer();
mTimer.start(method(:timerCallback), 1000, true);
}
public function onHide() as Void {
log("g.onHide");
if (mTimer != null) {
mTimer.stop();
mTimer = null;
}
}
hidden function timerCallback() as Void {
WatchUi.requestUpdate();
}
public function onUpdate(dc as Dc) as Void {
// Call the parent onUpdate function to redraw the layout
View.onUpdate(dc);
var text = "whatever";
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);
}
}