1
00:00:00,150 --> 00:00:01,950
We'll come back at this point.

2
00:00:01,980 --> 00:00:05,870
We will need to go on with where we finished in the last video.

3
00:00:05,880 --> 00:00:13,200
So let's get started and we start with setting up the text and the image that we want to set.

4
00:00:13,830 --> 00:00:15,480
Then we can go ahead and.

5
00:00:17,100 --> 00:00:18,210
Set those things.

6
00:00:19,590 --> 00:00:23,010
And the best spot for that would be the set up exercise for you.

7
00:00:23,430 --> 00:00:26,880
So here we want to set everything up, right?

8
00:00:26,890 --> 00:00:33,110
So once the progress bar is set up, we also can set up the time.

9
00:00:33,120 --> 00:00:37,740
So every image, that's a variable that I will create in a second there.

10
00:00:37,770 --> 00:00:40,180
I want to set the image source to be the image.

11
00:00:40,860 --> 00:00:43,140
OK, so an activity exercise.

12
00:00:43,140 --> 00:00:45,390
We need to create this image for you.

13
00:00:46,480 --> 00:00:48,260
So at which point does it make sense?

14
00:00:48,280 --> 00:00:54,640
Well, in the Linera layout, just above that text, so here we have this linear layout, which is our

15
00:00:55,060 --> 00:01:01,660
exercise view, and we have our text you where we need to create the image here.

16
00:01:02,560 --> 00:01:05,470
So we want to have an image view.

17
00:01:06,070 --> 00:01:07,710
Now, what about this image of you?

18
00:01:07,780 --> 00:01:11,800
Well, it should be matching the parent then its height.

19
00:01:12,850 --> 00:01:22,930
Should be zero DP, so I'm going to set it to zero DP for now and it will then just take the size of

20
00:01:22,930 --> 00:01:26,480
whatever we have as the the image size.

21
00:01:26,500 --> 00:01:26,800
All right.

22
00:01:26,800 --> 00:01:28,500
So we will fit it later on.

23
00:01:28,810 --> 00:01:29,860
And how do we fit it?

24
00:01:29,860 --> 00:01:31,500
Well, with scale types.

25
00:01:31,500 --> 00:01:36,920
So there is this variable called scale type and we can set it to fit X and Y.

26
00:01:37,150 --> 00:01:39,660
So just going to fit the image into the screen.

27
00:01:40,180 --> 00:01:46,150
So if you want to know more about the different fit types, you can test all of them and see which does

28
00:01:46,150 --> 00:01:46,450
what.

29
00:01:46,810 --> 00:01:55,030
All right, then I will set the layout weight to be one and I'm going to give this a little description.

30
00:01:55,030 --> 00:01:58,210
So content description is something that you.

31
00:01:59,750 --> 00:02:00,920
Can give here.

32
00:02:01,900 --> 00:02:05,180
And I'm just going to give the string image here.

33
00:02:05,710 --> 00:02:07,090
So what's the idea behind this?

34
00:02:07,120 --> 00:02:07,540
Well.

35
00:02:08,900 --> 00:02:13,410
If a blind person tries to use this app, then this could be red.

36
00:02:13,430 --> 00:02:18,710
So whatever text we have behind string image, so here they'll use.

37
00:02:20,540 --> 00:02:26,900
Strings and we have this image and here is just an image, but we could say something like exercise

38
00:02:27,590 --> 00:02:34,160
image here, and then the person would understand a little more what the idea behind this thing is.

39
00:02:34,340 --> 00:02:34,850
All right.

40
00:02:36,210 --> 00:02:37,110
So now.

41
00:02:38,310 --> 00:02:43,710
Let's go back to our activity exercise, we need to give this imagery an idea, so it's it's best to

42
00:02:43,710 --> 00:02:44,820
have the I.D. at the top.

43
00:02:44,820 --> 00:02:46,530
And I'm going to call this one I've image.

44
00:02:47,040 --> 00:02:51,440
So I've standing for image view and then, of course, image.

45
00:02:51,990 --> 00:02:55,840
Now we can set a source for this directly.

46
00:02:55,860 --> 00:03:01,500
So which is probably not such a bad idea, because just in case that the image is not loaded directly

47
00:03:01,500 --> 00:03:06,450
and it is not displayed, we can set the default image for this image straight from the start.

48
00:03:06,720 --> 00:03:09,390
And I'm just going to use drawable.

49
00:03:09,840 --> 00:03:15,870
And here I see underscore jumping jacks because that's the first exercise, right?

50
00:03:16,200 --> 00:03:21,510
Because if we look at our constants, we can see Volle Jumping Jacks is the first exercise which has

51
00:03:21,510 --> 00:03:22,440
an idea of one.

52
00:03:22,440 --> 00:03:26,820
So it makes sense to display this exercise as the first one.

53
00:03:28,830 --> 00:03:29,210
All right.

54
00:03:29,250 --> 00:03:36,780
And now we can go ahead and use this I.V. image here and we can set its value so we can go ahead and

55
00:03:36,780 --> 00:03:40,440
say set image resource.

56
00:03:42,010 --> 00:03:50,950
And here we have a much bitmap image Straubel But I have a resource here, which is my exercise list.

57
00:03:52,200 --> 00:03:53,510
We saw earlier is another.

58
00:03:53,530 --> 00:03:58,840
All right, so we need to use exclamation marks if you want to use it, and then I'm going to use the

59
00:03:58,840 --> 00:04:03,450
current exercise position that get image.

60
00:04:04,330 --> 00:04:05,410
So why am I doing that?

61
00:04:05,620 --> 00:04:09,060
Well, let's look at our exercise list real quick.

62
00:04:09,430 --> 00:04:15,730
We can see our exercise list isn't a list of type array list, which contains exercise models, and

63
00:04:15,730 --> 00:04:16,269
it's a nullable.

64
00:04:16,269 --> 00:04:17,740
So it's sad to know.

65
00:04:17,890 --> 00:04:21,610
But of course, later on we said it, but it's still going to be.

66
00:04:22,870 --> 00:04:33,250
All type lists and or array list, so if you want to access a part in there, so I index in there,

67
00:04:33,580 --> 00:04:35,740
we need to set a value in here.

68
00:04:35,950 --> 00:04:42,850
So here in the first for the first exercise, it will be zero, then it will be one, two, three and

69
00:04:42,850 --> 00:04:43,360
so forth.

70
00:04:43,660 --> 00:04:51,850
So I'm just going to use this current exercise position to display the right exercise and then I get

71
00:04:51,850 --> 00:04:52,870
the image from that.

72
00:04:52,900 --> 00:04:53,980
What is the cat image?

73
00:04:54,010 --> 00:04:59,680
Well, if we look at our get or exercise model, we can see that we have this variable called image

74
00:05:00,040 --> 00:05:04,810
and then we have this geto function get image which returns the image.

75
00:05:04,810 --> 00:05:06,350
And which image is it going to return?

76
00:05:06,370 --> 00:05:13,750
Well, it's going to return the our drawable I see jumping jacks, so it's just going to return the

77
00:05:13,750 --> 00:05:21,790
image of our jumping jacks and then in the next iteration it's going to return to icy Wall Street and

78
00:05:21,790 --> 00:05:22,360
so forth.

79
00:05:23,360 --> 00:05:29,570
Now, there is something about the idea now you might wonder, well, I'm using it one here and here,

80
00:05:29,570 --> 00:05:35,660
I'm using the current exercise position, which we initialized with minus one, which we then increased

81
00:05:36,020 --> 00:05:38,420
by one once the exercise started.

82
00:05:38,690 --> 00:05:45,070
So we are at position zero instead of ID one, which we had for our jumping jacks.

83
00:05:45,080 --> 00:05:47,480
So why should it still display jumping jacks?

84
00:05:47,840 --> 00:05:49,560
Well, there is a distinction to make.

85
00:05:50,090 --> 00:05:59,270
So exercise model has these IDs, but they are not the the numbers or the indices, the index numbers

86
00:05:59,630 --> 00:06:00,620
of our.

87
00:06:01,730 --> 00:06:09,650
List that we have here, so of our exercise list, because the exercise list has its own index indexes

88
00:06:09,890 --> 00:06:11,040
and it starts at zero.

89
00:06:11,480 --> 00:06:14,510
So the first entry in that list is going to be zero.

90
00:06:15,860 --> 00:06:23,270
Or the index for the first entry, and that is our first exercise that we have in the list and the first

91
00:06:23,270 --> 00:06:25,520
exercise that we have is in the list is the jumping jacks.

92
00:06:27,010 --> 00:06:29,410
All right, so coming back.

93
00:06:30,540 --> 00:06:37,620
And this video is a lot longer than I was anticipating, but we are at the point where we set the image

94
00:06:37,620 --> 00:06:41,390
resource and now we only need to set the exercise name.

95
00:06:41,760 --> 00:06:43,220
So let's set the exercise.

96
00:06:43,220 --> 00:06:43,710
Nice name.

97
00:06:43,710 --> 00:06:49,130
So it's text to exercise list DOT or here.

98
00:06:49,140 --> 00:06:52,860
Actually, it's also the current exercise position.

99
00:06:53,700 --> 00:06:54,400
Dot, good name.

100
00:06:54,840 --> 00:06:59,370
So here, instead of getting the image, we get the name, which means that if we look at our concerns,

101
00:06:59,370 --> 00:07:05,250
we get the variable this year as it says here, name jumping jacks.

102
00:07:07,210 --> 00:07:14,350
All right, so now there's one less thing to set, and that's, of course, to.

103
00:07:15,840 --> 00:07:18,810
Said our exercise correctly.

104
00:07:18,840 --> 00:07:25,710
So I started the code already, but we need to do one more step and that is in our set exercise progress

105
00:07:25,950 --> 00:07:26,730
bar.

106
00:07:27,930 --> 00:07:36,540
Here on finish, so once we finish the exercise, what I want to do is not only to show a text which

107
00:07:36,540 --> 00:07:41,420
says here we will start the next screen, but actually start the next screen.

108
00:07:42,030 --> 00:07:47,530
And that is linked to something where we have to be very careful.

109
00:07:47,910 --> 00:07:56,700
So if the current exercise position is less than 11, then please set up the rest of you, set up rest

110
00:07:56,700 --> 00:07:56,910
of you.

111
00:07:57,570 --> 00:08:04,650
But if it's not so if we are at Exercise 12 already after exercise 12, we don't want to display the

112
00:08:04,650 --> 00:08:07,820
rest of you again, but we want to display the finish for you.

113
00:08:07,830 --> 00:08:14,160
So the ending view where we say congratulations, you finished a seven minute workout app or the seven

114
00:08:14,160 --> 00:08:14,820
minute workout.

115
00:08:15,390 --> 00:08:16,020
Great job.

116
00:08:16,260 --> 00:08:21,480
So what I'm going to do there is I'm just going to post a toast here for now, which is just going to

117
00:08:21,480 --> 00:08:22,560
say congratulations.

118
00:08:22,560 --> 00:08:24,330
You have completed the seven minute workout.

119
00:08:26,110 --> 00:08:31,870
OK, so in order to test that, we could, of course, go ahead and save the position is less than one,

120
00:08:32,350 --> 00:08:34,980
so that would be a good number to test.

121
00:08:35,200 --> 00:08:39,760
And of course, we could also go ahead and make it less.

122
00:08:41,159 --> 00:08:51,660
Let's say let's hardcoded and just look at, um, exercise lists that size minus one, so that's the

123
00:08:51,660 --> 00:08:53,270
thing here about this exercise list.

124
00:08:53,280 --> 00:08:55,320
It is an option or a nullable.

125
00:08:55,320 --> 00:08:55,740
Right.

126
00:08:56,040 --> 00:09:04,620
But we unwrap it until we get that size and then we subtract one because it starts at zero.

127
00:09:04,620 --> 00:09:04,900
Right.

128
00:09:04,920 --> 00:09:07,920
If the size is 12 and it starts at zero.

129
00:09:07,920 --> 00:09:15,240
So we need to reduce one here in order to make sure that it's not going to get to the rest of you after

130
00:09:15,240 --> 00:09:16,150
the last exercise.

131
00:09:16,500 --> 00:09:16,770
All right.

132
00:09:16,800 --> 00:09:20,400
So this would be an alternative to just entering 11 here.

133
00:09:20,610 --> 00:09:24,060
So the way you prefer is what you can go with.

134
00:09:24,390 --> 00:09:33,840
This is the sure or safe way that even if we later on decide to change the amount of exercises here

135
00:09:33,840 --> 00:09:37,880
in the exercise list, that it's still going to work.

136
00:09:39,600 --> 00:09:42,030
All right, and at this point, we can.

137
00:09:43,240 --> 00:09:45,580
Test it, so let's go ahead and test this.

138
00:09:46,610 --> 00:09:48,110
So let's play start.

139
00:09:50,200 --> 00:09:51,860
And now let's see what's going to happen.

140
00:09:51,880 --> 00:09:58,000
Get ready with the jumping jacks pops up and we can also see the image pops up.

141
00:09:58,270 --> 00:10:02,640
And I'm just going to post a video real quick until the timer is almost done.

142
00:10:03,890 --> 00:10:09,080
Just to see if it then goes over to the rest of you after the timer is over.

143
00:10:10,310 --> 00:10:11,580
So there we are.

144
00:10:12,290 --> 00:10:17,330
And as you can see, we didn't get the rest of you, but 10 seconds later, the next exercise popped

145
00:10:17,330 --> 00:10:17,500
up.

146
00:10:17,720 --> 00:10:20,680
So there we have a little issue still in our coat.

147
00:10:20,690 --> 00:10:21,580
So let's fix that.

148
00:10:22,700 --> 00:10:29,080
And this has to do with a set of pressure now for you to try to figure out why it doesn't work.

149
00:10:31,790 --> 00:10:36,800
All right, I'll tell you, I hope you figured it out, it has to do with the visibility so we are not

150
00:10:36,800 --> 00:10:37,760
setting it visible.

151
00:10:38,030 --> 00:10:40,760
So we need to set that visible again.

152
00:10:41,330 --> 00:10:43,510
And the same goes for the exercise of you.

153
00:10:43,760 --> 00:10:45,500
We need to make it invisible.

154
00:10:45,500 --> 00:10:46,970
So view that gone.

155
00:10:47,910 --> 00:10:56,580
All right, because in the set up exercise video, we did set the ones so the rest of you has gone and

156
00:10:56,790 --> 00:11:00,430
exercise you as visible, but we never set it back.

157
00:11:00,450 --> 00:11:04,690
So instead of rescue, we now do the opposite or we do the switch.

158
00:11:04,920 --> 00:11:06,240
So now let's run this again.

159
00:11:06,840 --> 00:11:10,470
And I'm just going to cut to the point where it's actually important.

160
00:11:10,500 --> 00:11:14,040
So at the end of the first exercise, what it's going to switch.

161
00:11:14,850 --> 00:11:21,570
And by the way, for the purpose of testing, it really makes sense to reduce those timers to two or

162
00:11:21,570 --> 00:11:27,030
three seconds, because then you can really quickly test especially this behavior because you don't

163
00:11:27,030 --> 00:11:33,970
want to wait for 30 seconds or even 40 seconds each time just to see if a functionality works as intended.

164
00:11:34,470 --> 00:11:35,490
But here we are.

165
00:11:35,490 --> 00:11:37,770
Jumping jacks goes from one to zero.

166
00:11:37,770 --> 00:11:41,120
And then we get back to our rescue, get ready for.

167
00:11:41,130 --> 00:11:46,710
And there, of course, it should display the name of the next exercise at one point, but now it doesn't.

168
00:11:47,040 --> 00:11:47,980
And there we are.

169
00:11:48,030 --> 00:11:51,240
Next exercise wohlsen so we can see the transition worked.

170
00:11:51,240 --> 00:11:52,540
And that is great.

171
00:11:52,920 --> 00:11:54,380
So I hope you enjoyed this video.

172
00:11:54,390 --> 00:11:55,500
It was a super long one.

173
00:11:55,620 --> 00:11:58,260
I'll probably cut it into two, but that's just how it is.

174
00:11:58,260 --> 00:12:03,510
Some functionality is they need a little time to set up, especially because we set it up in a very

175
00:12:03,510 --> 00:12:04,140
clean way.

176
00:12:04,140 --> 00:12:08,550
We have a model, we have a constant which we can at any time adjust.

177
00:12:08,730 --> 00:12:15,450
And we made it so that our application is easily extendable later on and maintainable.

178
00:12:15,450 --> 00:12:20,100
So that's a thing that you really need to take into consideration when building your apps, because

179
00:12:20,100 --> 00:12:26,100
if you build your apps without these concepts in mind, then it will be really a pain to do that.

180
00:12:26,580 --> 00:12:26,950
All right.

181
00:12:26,950 --> 00:12:30,960
So see you in the next video and thanks for still being with me.

