1
00:00:00,480 --> 00:00:02,170
Welcome to the final lecture.

2
00:00:02,190 --> 00:00:07,890
In this video, we are going to finalize our application and we're going to finally see the history

3
00:00:08,130 --> 00:00:10,950
of all the different exercises that we finished.

4
00:00:11,220 --> 00:00:17,520
As you can see, the idea is that no data available will be displayed if there is no data available.

5
00:00:17,730 --> 00:00:18,090
All right.

6
00:00:18,090 --> 00:00:23,520
So that's a good practice to do because you don't want the user to not see anything.

7
00:00:23,520 --> 00:00:28,530
If there is no data to see, you should at least tell him that there's no data available.

8
00:00:28,770 --> 00:00:33,960
And maybe you can even add something like finish an exercise in order to see your history.

9
00:00:34,920 --> 00:00:41,300
Or you could even deactivate the history button and inform the user that there is no data available

10
00:00:41,310 --> 00:00:45,830
and he should start an exercise first, or you could even hide the history button.

11
00:00:46,140 --> 00:00:47,880
So there are multiple different options.

12
00:00:47,880 --> 00:00:49,610
You just have to decide for one.

13
00:00:49,890 --> 00:00:56,790
And I personally like the idea that we have here where we say no data available and then once the user

14
00:00:56,790 --> 00:01:04,410
finishes the exercise, then he can see the different exercises that he has finished or the dates when

15
00:01:04,410 --> 00:01:05,580
he finished the exercise.

16
00:01:06,210 --> 00:01:07,230
All right, let's get started.

17
00:01:07,770 --> 00:01:12,840
We will need to have a recycler of you, because here I want to display, of course, all of the data

18
00:01:13,050 --> 00:01:14,130
in the recycle of you.

19
00:01:14,940 --> 00:01:20,440
And we will also, of course, need to have the XML file in which we want to display.

20
00:01:20,760 --> 00:01:24,420
So activity history is going to be the one that I want to display it in.

21
00:01:24,720 --> 00:01:27,660
And I'm just going to post the code in here and go through it.

22
00:01:27,930 --> 00:01:30,390
So I'm just going to use a linear layout here.

23
00:01:32,370 --> 00:01:39,540
At the very top, this linear layout will match its parents and the orientation will be vertical.

24
00:01:41,080 --> 00:01:48,490
And when I insert that, you can see that here, our highest linear layout, so the container everything

25
00:01:48,490 --> 00:01:49,880
is in is complaining.

26
00:01:49,900 --> 00:01:53,130
So I also need to add an orientation in here.

27
00:01:53,260 --> 00:01:55,150
So I'm going to make that vertical as well.

28
00:01:55,600 --> 00:02:04,630
OK, so this is our linear layout in which I have to text you, which just says exercise completed and

29
00:02:04,690 --> 00:02:06,130
has a text size of 18.

30
00:02:06,130 --> 00:02:07,870
Divisibility is gone.

31
00:02:07,880 --> 00:02:11,220
So it's not even so it won't appear at all.

32
00:02:11,470 --> 00:02:14,280
But of course I still want to see it in here.

33
00:02:14,290 --> 00:02:20,590
So you can see I have this little area which says exercise completed and then all of the different items

34
00:02:20,620 --> 00:02:21,400
underneath it.

35
00:02:23,220 --> 00:02:23,790
And then.

36
00:02:24,980 --> 00:02:26,270
I have my respect of you.

37
00:02:28,390 --> 00:02:33,700
Which is going to contain all the different elements, all the different entries that we have, the

38
00:02:33,820 --> 00:02:35,630
visibility is also set to go on.

39
00:02:36,040 --> 00:02:37,110
I have a little margin.

40
00:02:37,120 --> 00:02:38,870
Of course, they all have IDs, right.

41
00:02:38,890 --> 00:02:46,030
So this takes you has an I.D. then our cycle of you has an ID and then the text you on the also has

42
00:02:46,030 --> 00:02:50,050
an ID which says TV, no data available.

43
00:02:50,350 --> 00:02:54,910
And that one is going to be used, of course, to make it visible or invisible.

44
00:02:54,910 --> 00:03:02,740
So we want to make this text at one point invisible, this TextView, because as soon as we have data,

45
00:03:02,740 --> 00:03:04,880
we don't want to say that we don't have any data.

46
00:03:05,560 --> 00:03:06,010
All right.

47
00:03:06,320 --> 00:03:09,190
And that's pretty much the layout that we want to use.

48
00:03:09,430 --> 00:03:16,420
Now, the next thing we need to do is we need to go to our app here and create a new.

49
00:03:17,350 --> 00:03:21,940
Adapter, so I'm just going to create a new file here and you Coppen plus.

50
00:03:22,850 --> 00:03:26,930
And I'm going to call this one history adapter.

51
00:03:31,090 --> 00:03:37,180
Now, the history adapter should inherit from recycler view dot adapter.

52
00:03:38,870 --> 00:03:44,630
OK, and our history adapters should have a constructor where it gets the context.

53
00:03:46,670 --> 00:03:53,900
Which is going to be of type context, and it gets items which will be of type array list.

54
00:03:55,640 --> 00:03:56,120
String.

55
00:03:58,000 --> 00:04:03,430
Now, context is complaining because it doesn't exist in this context, so we need to import context

56
00:04:03,820 --> 00:04:05,680
and then our adapter.

57
00:04:08,010 --> 00:04:15,030
Needs to have a view holder now in order to assign a view holder to it, we need to create a new class

58
00:04:15,030 --> 00:04:17,089
that I want to use as its new holder.

59
00:04:17,459 --> 00:04:19,709
So let's go ahead and create a new class in here.

60
00:04:19,829 --> 00:04:30,870
Class view holder, which will require a view and which will inherit from recycled view that Holder.

61
00:04:32,630 --> 00:04:37,090
All right, so, of course, we need to import view as well.

62
00:04:38,270 --> 00:04:39,860
And what we want to have in here.

63
00:04:40,130 --> 00:04:42,200
Well, first of all, our.

64
00:04:43,290 --> 00:04:43,980
History.

65
00:04:46,840 --> 00:04:53,500
Main item, which will be viewed, not L'il history.

66
00:04:56,010 --> 00:04:56,280
Mean.

67
00:04:57,590 --> 00:05:01,130
And then I want to have the TV item and the TV position.

68
00:05:02,130 --> 00:05:12,990
All right, so what TV item is going to be our view, that TV item and then Voll TV position?

69
00:05:14,710 --> 00:05:17,140
It's going to be our view that TV.

70
00:05:18,260 --> 00:05:18,770
Position.

71
00:05:19,490 --> 00:05:27,690
So basically, it's going to be the ones that we have and this item, History Row, TV item and TV position,

72
00:05:27,740 --> 00:05:34,850
so this XML file, which we prepared in the last video and also this linear layout called a little history

73
00:05:34,850 --> 00:05:35,210
item.

74
00:05:35,960 --> 00:05:38,680
So basically the custom roll that we prepared.

75
00:05:39,620 --> 00:05:41,240
So that's going to be the view holder.

76
00:05:41,660 --> 00:05:46,520
And now I can, of course, go ahead and say that I want to use the fueler here.

77
00:05:49,690 --> 00:05:51,110
And where is this view, Holder?

78
00:05:51,130 --> 00:05:56,650
It's in our history adaptor history adapter, dot view holder.

79
00:05:59,090 --> 00:06:03,690
All right, now our history adapter needs to implement all the members that are still missing.

80
00:06:03,710 --> 00:06:08,840
So uncreate, you, holder get item count and unbind view holder.

81
00:06:09,140 --> 00:06:10,010
So that's important.

82
00:06:10,010 --> 00:06:10,580
All of those.

83
00:06:13,300 --> 00:06:18,340
And let's implement them, so what do we want to do once we create?

84
00:06:19,420 --> 00:06:29,350
The Bueler well, here I want to return the view hold object and what should it have as its layout.

85
00:06:29,680 --> 00:06:36,070
So layout inflator that from context that inflate.

86
00:06:37,010 --> 00:06:40,880
Our dot layout, that item history wrote.

87
00:06:45,470 --> 00:06:53,570
And then we need to pass in the parents and finally the attached to root value, and I'm just going

88
00:06:53,570 --> 00:06:54,710
to present false.

89
00:06:56,240 --> 00:07:01,800
OK, so the parents, that's what we get from here and the touch, the root, we just set it false.

90
00:07:02,580 --> 00:07:09,320
OK, so that's going to be the view holder that we're going to return when we create or when the uncreate

91
00:07:09,320 --> 00:07:13,820
view holder function is called from our history adapter class.

92
00:07:15,380 --> 00:07:16,790
So here I can count.

93
00:07:16,850 --> 00:07:18,710
What do you want to return there, their.

94
00:07:20,880 --> 00:07:31,920
Well, the items such as return items, but size, what is items, well, items is what we get when

95
00:07:31,920 --> 00:07:34,090
an object of the history adapter is created.

96
00:07:34,290 --> 00:07:36,120
So we need it to pass the items.

97
00:07:38,320 --> 00:07:40,420
And then we have to unbind V. Holder.

98
00:07:43,420 --> 00:07:45,010
And this is where we actually.

99
00:07:45,920 --> 00:07:50,730
Point to data, to the list, to you or to the recycler of you.

100
00:07:51,500 --> 00:07:51,830
All right.

101
00:07:51,860 --> 00:07:57,020
So if any of this is too fast for you, then please check out the recycled video once again, because

102
00:07:57,020 --> 00:07:58,970
there I explain everything in more detail.

103
00:07:59,240 --> 00:08:04,190
But basically what I need is the dates that I want to display, which is going to be of type string.

104
00:08:04,190 --> 00:08:07,850
And I get it from items that get position.

105
00:08:08,660 --> 00:08:15,710
So whatever position we currently in, I want to get it from the array list that we get past when we

106
00:08:15,710 --> 00:08:17,420
create an history adapter object.

107
00:08:18,330 --> 00:08:23,750
And then I want to display that and I want to display it correctly, so what I'm going to say is Holder

108
00:08:23,760 --> 00:08:25,650
Dots TV position.

109
00:08:26,660 --> 00:08:32,750
The text should be said to the position plus one.

110
00:08:34,059 --> 00:08:37,659
As a string, so here to string.

111
00:08:39,600 --> 00:08:45,620
So the position starts at zero, and that's the thing, I don't want to have the first entry at zero,

112
00:08:45,630 --> 00:08:47,470
I want the first entry to be at one.

113
00:08:47,490 --> 00:08:49,020
That's why I add one to it.

114
00:08:50,270 --> 00:08:56,570
And then we can go ahead and set also the text of it, so holder that TV.

115
00:08:58,380 --> 00:09:02,970
Item, that text should be the date.

116
00:09:04,560 --> 00:09:10,830
So the date that we got from the item itself, so it's just going to set those two text views here.

117
00:09:12,520 --> 00:09:16,180
So this will be the position and this will be the date.

118
00:09:17,450 --> 00:09:24,080
That's what we do in our history, adeptness, what's what's happening here, basically, and then I

119
00:09:24,080 --> 00:09:24,710
want to.

120
00:09:27,060 --> 00:09:34,710
Move around between a great color and a white color has the background, so here I call this one little

121
00:09:34,710 --> 00:09:36,300
history main item.

122
00:09:38,340 --> 00:09:45,240
Like this, so the holder of his three main items set back on color and basically I'm just setting the

123
00:09:45,240 --> 00:09:54,420
background color off the list element or the list item to either be this almost white color and this

124
00:09:54,420 --> 00:09:55,020
white color.

125
00:09:56,320 --> 00:10:00,400
So every second one will be great and every other second one will be white.

126
00:10:02,230 --> 00:10:02,770
All right.

127
00:10:03,100 --> 00:10:09,490
And now in our history activity, we had this function called get all complete dates.

128
00:10:09,910 --> 00:10:15,100
And now instead of putting it to the log, we want to put it onto our recital of you.

129
00:10:15,290 --> 00:10:16,890
So we wanted this displayed there.

130
00:10:17,320 --> 00:10:22,590
So what we can check here is if we even have any entries.

131
00:10:22,720 --> 00:10:23,680
So here, if.

132
00:10:25,430 --> 00:10:28,640
All completed dates list is.

133
00:10:30,280 --> 00:10:35,680
Greater so its size is greater than zero, then we know that we have at least one entry in their.

134
00:10:36,760 --> 00:10:38,770
And then we can go ahead and say.

135
00:10:40,000 --> 00:10:47,020
TV history should be set to visible, so its visibility should be set to view.

136
00:10:48,250 --> 00:10:57,010
That visible and recycled view, history or history should also be made visible, so visibility view

137
00:10:57,010 --> 00:10:58,270
that visible.

138
00:11:00,970 --> 00:11:08,350
When the TV no data available, so the text with no data available, visibility should be set to count.

139
00:11:08,830 --> 00:11:10,000
Some of you that got.

140
00:11:12,560 --> 00:11:17,960
And now we can finally fill up our R.V. history, which is our recital of you history.

141
00:11:18,080 --> 00:11:18,770
So here.

142
00:11:20,430 --> 00:11:23,790
This one here, this recycle of you, we can fill it up.

143
00:11:25,240 --> 00:11:32,320
And we fill it with some information, first of all, we give it a layout, so I'm going to set the

144
00:11:32,320 --> 00:11:35,710
layout manager to be a linear layout manager.

145
00:11:37,050 --> 00:11:45,420
With this as the context and then I need a history adapter, which will be my history adapter, so I

146
00:11:45,420 --> 00:11:49,110
create an object of my history adapters of this class that I prepared.

147
00:11:50,810 --> 00:11:55,580
And then, of course, I need to pass in the context so this and analyst.

148
00:11:56,640 --> 00:12:01,050
And you guessed it, this all completed states list is an array list.

149
00:12:02,370 --> 00:12:07,080
Of strength, because we get it from get all complete states this and that's unrealistic, right?

150
00:12:07,560 --> 00:12:12,530
So that's exactly what we need in our history activity here when creating a history adaptor.

151
00:12:12,780 --> 00:12:13,170
All right.

152
00:12:13,180 --> 00:12:15,960
So here it says, I want to have an array list of strings.

153
00:12:17,660 --> 00:12:25,660
Now we can go ahead and set the adapter of our arvi history to be the history adapter that we prepared,

154
00:12:26,150 --> 00:12:28,370
so our history adapter object.

155
00:12:29,640 --> 00:12:36,870
And then, of course, if we have no values whatsoever and sort of our all complete dates list, then

156
00:12:36,870 --> 00:12:42,030
we want to make the opposite of what we did here or do the opposite.

157
00:12:42,090 --> 00:12:44,010
So here, this one should be gone.

158
00:12:44,610 --> 00:12:47,070
So our TV history should be gone.

159
00:12:48,420 --> 00:12:54,600
And our Harvey history as well, but our TV, no data available should be set to visible.

160
00:12:57,480 --> 00:13:04,320
All right, and now we can run our application and see if the two dates that we already had in there

161
00:13:04,650 --> 00:13:05,820
are actually going to be.

162
00:13:07,290 --> 00:13:07,830
Appearing.

163
00:13:08,760 --> 00:13:12,120
So that we are history and as you can see.

164
00:13:13,060 --> 00:13:20,200
First entry, second entry, then the two dates that we had last time exercise completed and that we

165
00:13:20,200 --> 00:13:23,290
are, of course, you can make this a lot more beautiful.

166
00:13:23,300 --> 00:13:30,790
So here you can change the title to be exercise completed and get rid of this area here or.

167
00:13:31,830 --> 00:13:34,890
Whatever you think of, so you can make it as beautiful as you want.

168
00:13:35,350 --> 00:13:36,150
Now let's test it.

169
00:13:36,150 --> 00:13:37,920
Let's finish an exercise.

170
00:13:40,340 --> 00:13:41,500
All right, almost done.

171
00:13:42,900 --> 00:13:49,020
And that was a very quick one, so let's finish it, let's go to the history and we can see that the

172
00:13:49,020 --> 00:13:51,340
third exercise is in there as well.

173
00:13:51,630 --> 00:13:58,680
So this list is, of course, a recycled view and we can drag around if we had more entries here.

174
00:13:58,980 --> 00:14:00,900
But, yeah, that's pretty much it already.

175
00:14:01,380 --> 00:14:07,050
Now, you could, of course, go ahead and change the whole list items here instead of just having the

176
00:14:07,050 --> 00:14:07,410
number.

177
00:14:07,410 --> 00:14:09,880
And to date, you could also add an image.

178
00:14:09,910 --> 00:14:17,700
Then you could lead to a different screen in which the user can upload his image that we want the way

179
00:14:17,700 --> 00:14:26,280
he looked after the workout or the way she looks in general, maybe just to see how the progresses in

180
00:14:26,280 --> 00:14:26,910
comparison.

181
00:14:26,920 --> 00:14:31,890
So maybe a person wants to lose weight, then they want to keep the progress.

182
00:14:32,230 --> 00:14:36,200
So each time they finish the exercise, they made an image and they want to store it here.

183
00:14:36,360 --> 00:14:37,490
So that would be an option.

184
00:14:37,710 --> 00:14:39,060
That's something that you can do.

185
00:14:39,060 --> 00:14:45,660
And you will learn how to do that in the next chapter, actually, because we are going to create a

186
00:14:45,660 --> 00:14:51,210
happy places at which you then can use to feed yourself and implement them here.

187
00:14:51,210 --> 00:14:57,780
So you can once you are done with the other exercise, come back here and complete this or extend the

188
00:14:57,780 --> 00:14:58,620
features of this.

189
00:14:59,220 --> 00:15:01,290
And this is not part of the course.

190
00:15:01,290 --> 00:15:03,810
But if you want to do that, please go ahead and try that.

191
00:15:03,810 --> 00:15:10,080
Once you're done with the Happy Places chapter and if you want to share your code, feel free to do

192
00:15:10,080 --> 00:15:10,430
so.

193
00:15:10,710 --> 00:15:14,190
It's definitely interesting for the other students as well.

194
00:15:14,880 --> 00:15:15,260
All right.

195
00:15:15,270 --> 00:15:18,180
So thanks a lot for staying with me for this journey.

196
00:15:18,400 --> 00:15:23,880
And now we're finally done with our seven minute workout app and I'd say see you in the next chapter.

