1 00:00:03,820 --> 00:00:09,889 G'day everyone, welcome back. In the last two videos, we wrote the code to save the 2 00:00:09,889 --> 00:00:16,129 timing data. In this video, we'll make sure it's working. We've written the time 3 00:00:16,129 --> 00:00:22,520 Task function in our viewModel. To use it, we'll call it in the onTaskLong 4 00:00:22,520 --> 00:00:27,610 Click function, in the MainActivityFragment. 5 00:00:36,020 --> 00:00:42,410 Okay, I'll run the app to make sure it works. I'm using an emulator that isn't a 6 00:00:42,410 --> 00:00:47,240 Google Play emulator, which makes checking the database easier, without 7 00:00:47,240 --> 00:00:51,890 having to drag it back to my computer to check it. If you're using a physical 8 00:00:51,890 --> 00:00:59,480 device, you'll have to use the device file explorer to check your database. 9 00:00:59,480 --> 00:01:03,560 We've got a bit more work to do yet, and at the moment, there's no visual 10 00:01:03,560 --> 00:01:10,580 indication when a task is long-tapped. that makes testing interesting. 11 00:01:10,580 --> 00:01:20,840 Fortunately, we've got the logcat. I'll make sure it's visible and clear before continuing. 12 00:01:20,840 --> 00:01:26,660 When I long-tap a task, we get the entries appearing in the logcat. 13 00:01:32,840 --> 00:01:37,490 You should see a new record being inserted into the database on a separate 14 00:01:37,490 --> 00:01:42,470 thread. Switching to the terminal tab, I'll start a shell on the device and 15 00:01:42,470 --> 00:01:48,259 examine the database. When you run sqlite on an emulator, you can't use the 16 00:01:48,259 --> 00:01:53,179 cursor keys to repeat a command. That's mildly annoying, because I want to run 17 00:01:53,179 --> 00:01:57,979 the same query against the timingsTable several times. The sqlite 3 18 00:01:57,979 --> 00:02:02,869 command line lets you specify a query when you run it. It executes the query, 19 00:02:02,869 --> 00:02:07,700 then terminates, which is handy. That means I can repeat the sqlite 3 20 00:02:07,700 --> 00:02:11,830 command, using my up arrow key. 21 00:02:33,130 --> 00:02:37,690 I don't think I've used sqlite 3 three like that before. I can use the 22 00:02:37,690 --> 00:02:42,440 up arrow to repeat the query, without having to type it again. 23 00:02:42,440 --> 00:02:47,460 Alright, there's our new row in the timings Table. Back on the emulator, 24 00:02:47,470 --> 00:02:51,700 I'll long-tap another task. That should update the duration column for the 25 00:02:51,700 --> 00:02:56,640 current task, then add a new row for the new task. 26 00:03:02,540 --> 00:03:04,200 I tapped a few times. 27 00:03:04,210 --> 00:03:10,030 There's the previous row, now with a non-zero duration, and the new records 28 00:03:10,030 --> 00:03:21,400 that were added. When I long-tap the second task again, the app stops timing 29 00:03:21,400 --> 00:03:27,130 and updates the database with the duration. So that's looking good. Well, 30 00:03:27,130 --> 00:03:31,870 it's not looking good, but it's behaving well. At the moment, there's no indication 31 00:03:31,870 --> 00:03:39,090 that a task is being timed. We'll add that in the next video. I'll see you then.