Smart Watch

Smart Watch – Part 2

In the previous article we looked at some of the considerations that we must make for developing apps for the smaller form factor of the i’m watch Android smart watch, and outlined the football timer app that we will look at in this article.

I'm WatchAs was mentioned previously, the app was tested during the English Championship match between my beloved Watford FC and Sheffield Wednesday on Saturday 14th December 2013. The app performed well, and the timings that we got certainly tallied with the stoppage time added on by the referee, but as for the performance of my team… I just don’t want to talk about it, OK?

Anyway, let’s start by looking at the single layout of the app:

We have the five different times that were mentioned in the pervious article: In the top left corner is the current time of day; in the top right corner is the actual time played (the total time minus the stoppages); in the bottom left is the duration of the current stoppage (if the current state is Paused); in the bottom right is the total stoppage time; and in the centre is the gross time (the elapsed time since the start before stoppages have been subtracted).

Some of these times will be zero until we encounter a stoppage during the game, so all but the time of day and the gross time are invisible at the start. The actual time played plus the stoppage time should equal the gross time.

The logic is almost entirely pure Java, and we have a GestureDetector which handles the touch events which we’ll use to change states of our state machine, and also clear things:

Hopefully the logic here should be fairly straightforward, so I won’t bother explaining the details.

So, we have the layout and the basic state machine and timers, but what we’re lacking is the mechanism which will update the timers as the match is in progress. In the concluding article in this series we’ll get the timers connected up so that we have a functioning timer app.

The source code for this article can be found here.

Many thanks to Sebastiano Poggi and the rest of the folks at i’m SpA for arranging the loan device which have made this series of articles possible.

© 2013 – 2014, Mark Allison. All rights reserved.

CC BY-NC-SA 4.0 Smart Watch – Part 2 by Styling Android is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. Permissions beyond the scope of this license may be available at http://blog.stylingandroid.com/license-information.

Leave a Reply

Your email address will not be published. Required fields are marked *