Hi,
I tried to complete this project from Peter: click
I defined a new App
class JungleApp extends Application.AppBase {
function initialize() {
AppBase.initialize();
}
// onStart() is called on application start up
function onStart(state) {
}
// onStop() is called when your application is exiting
function onStop(state) {
}
//! Return the initial view of your application here
function getInitialView() {
return [ new JungleView() ];
}
}
and did some basic stuff in the JungleView class:
class JungleView extends WatchUi.DataField {
hidden var mValue;
function initialize() {
DataField.initialize();
}
// Display the value you computed here. This will be called
// once a second when the data field is visible.
function onUpdate(dc) {
//System.println(width);
dc.setColor(Gfx.COLOR_WHITE, Graphics.COLOR_TRANSPARENT);
//dc.drawText(width / 2, height / 2, Graphics.FONT_NUMBER_THAI_HOT, timeString, Graphics.TEXT_JUSTIFY_CENTER | Graphics.TEXT_JUSTIFY_VCENTER);
dc.setColor(Gfx.COLOR_BLUE, Graphics.COLOR_TRANSPARENT);
dc.drawText(120, 140, Graphics.FONT_SMALL, "I'm standard!", Graphics.TEXT_JUSTIFY_CENTER);
}
}
Then I defined another class which exteds the DataField as well:
using Toybox.WatchUi as Ui;
var width;
var heigth;
class CommonLogicView extends Ui.DataField {
// this is called whenever the screen needs to be updated
function onUpdate(dc) {
// Common update of the screen: Clear the screen with the backgroundcolor.
clearScreen(dc);
// We can also do common calculations here, in this case we'll just get the current time
//determineClockTime();
}
// clears the screen and stores the width & height in global variables
function clearScreen(dc) {
dc.clear();
width = dc.width;
height = dc.height;
System.println("Hallo, I am Common Logic");
}
}
I have written some device specific files as well, but anyway, I can't see the message "Hallo. I am common Logic" anywhere, so it seems that the code does not run at all. In my understanding the class CommonLogicView extends the Datafield class and I thought as soon as onUpdate is fired, the function in the CommonLogicView runs as well. Am I wrong?
Thanks for helping.