Guest User

random monkey c

a guest
Sep 11th, 2021
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.65 KB | None | 0 0
  1. import Toybox.Graphics;
  2. import Toybox.Lang;
  3. import Toybox.System;
  4. import Toybox.WatchUi;
  5.  
  6.  
  7. class sharinganView extends WatchUi.WatchFace {
  8.     var myBmp;
  9.  
  10.     function initialize() {
  11.         WatchFace.initialize();
  12.         myBmp = WatchUi.loadResource(Rez.Drawables.sharinganPhoto); //load the bitmap using your id in place of id_pic
  13.     }
  14.  
  15.     // Load your resources here
  16.     function onLayout(dc as Dc) as Void {
  17.         setLayout(Rez.Layouts.WatchFace(dc));
  18.     }
  19.     // Called when this View is brought to the foreground. Restore
  20.     // the state of this View and prepare it to be shown. This includes
  21.     // loading resources into memory.
  22.     function onShow() as Void {}
  23.  
  24.     // Update the view
  25.     function onUpdate(dc as Dc) as Void {
  26.         var x = 0,
  27.             y = 0; //upper left is at 10,10
  28.         dc.drawBitmap(x, y, myBmp);
  29.  
  30.         // Get and show the current time
  31.         var clockTime = System.getClockTime();
  32.         var timeString = Lang.format("$1$:$2$", [clockTime.hour, clockTime.min.format("%02d")]);
  33.         var view = View.findDrawableById("TimeLabel") as Text;
  34.         view.setText(timeString);
  35.  
  36.         // Call the parent onUpdate function to redraw the layout
  37.         View.onUpdate(dc);
  38.     }
  39.  
  40.     // Called when this View is removed from the screen. Save the
  41.     // state of this View here. This includes freeing resources from
  42.     // memory.
  43.     function onHide() as Void {}
  44.  
  45.     // The user has just looked at their watch. Timers and animations may be started here.
  46.     function onExitSleep() as Void {}
  47.  
  48.     // Terminate any active timers and prepare for slow updates.
  49.     function onEnterSleep() as Void {}
  50. }
Advertisement
Add Comment
Please, Sign In to add comment