1
00:00:00,450 --> 00:00:01,050
Welcome back.

2
00:00:01,380 --> 00:00:07,890
Now it's time to display the list of boards that we have, and in order to do so, we, of course,

3
00:00:07,890 --> 00:00:10,390
need to add some more code.

4
00:00:10,410 --> 00:00:11,290
So let's get started.

5
00:00:12,400 --> 00:00:19,240
Therefore, I'm going to go to the main activity and there we need to create a new function which will

6
00:00:19,240 --> 00:00:21,710
take care of populating our board.

7
00:00:22,210 --> 00:00:30,870
So let's go ahead and created here fun populate boards list to you.

8
00:00:31,530 --> 00:00:36,940
So I'm going to call it and we first need the boards list, which is going to be an array list of boards.

9
00:00:37,720 --> 00:00:39,460
So array list of board.

10
00:00:42,390 --> 00:00:45,510
And then we need to import board here.

11
00:00:48,190 --> 00:00:50,890
And we can start with a code for dysfunction.

12
00:00:51,430 --> 00:00:53,110
OK, so what do we want to do here?

13
00:00:53,560 --> 00:00:59,440
Well, first of all, we want to highlight the progress bar if it was loading before.

14
00:00:59,950 --> 00:01:02,050
So let's hide it then.

15
00:01:03,250 --> 00:01:07,720
We want to check if the borders list is empty or not or is zero or not.

16
00:01:07,750 --> 00:01:12,430
So both this size is greater zero if it's more than zero.

17
00:01:12,760 --> 00:01:20,820
What we know is that we can make our our V borders list visible so that the visibility to view that

18
00:01:20,860 --> 00:01:28,570
visible and then we can go ahead and make the TV no boards available text invisible.

19
00:01:28,990 --> 00:01:35,070
So we have visibility set to view dog gone because Invisibles are going to be enough.

20
00:01:35,080 --> 00:01:39,430
It actually has to get out of our whole layout.

21
00:01:41,570 --> 00:01:47,820
Then I'm going to tell my Archibald's list what kind of layout manager I want to use.

22
00:01:47,840 --> 00:01:58,550
So here layout manager will be a linear layout manager where I then pass this activity to and then I

23
00:01:58,550 --> 00:02:02,810
can set has fixed size to true.

24
00:02:04,310 --> 00:02:07,660
So that our boards list has a fixed size.

25
00:02:07,970 --> 00:02:08,449
All right.

26
00:02:08,610 --> 00:02:10,100
So that's what this function does.

27
00:02:11,250 --> 00:02:12,960
So reactive you function.

28
00:02:15,020 --> 00:02:18,770
And and that the changes cannot affect the size of the risk of you.

29
00:02:21,730 --> 00:02:25,130
Then, as always, with respect to views, they need an adapter, right?

30
00:02:25,600 --> 00:02:32,500
So let's prepare an adapter here, which will be our board items adapter that we created in the last

31
00:02:32,500 --> 00:02:33,490
video here.

32
00:02:33,490 --> 00:02:36,790
We needed to pass the context and the list that we want to use.

33
00:02:37,180 --> 00:02:39,340
That is that I want to use is the board's list.

34
00:02:40,030 --> 00:02:45,460
OK, so if you recall this item adapters, the class that we created in the last video, we needed to

35
00:02:45,460 --> 00:02:48,280
pass in the context and then a list of bords.

36
00:02:50,080 --> 00:02:57,580
OK, so that's what we do here and now we can assign that adapter to our boys list, so we bought list

37
00:02:57,670 --> 00:03:02,440
that there should be the adapter that we just created.

38
00:03:03,720 --> 00:03:12,420
And then if the wordlist is in fact empty, then we don't want to display our port list, but we want

39
00:03:12,420 --> 00:03:18,330
to do it the other way around, pretty much so here then our ports, this should be gone.

40
00:03:18,750 --> 00:03:22,770
And the text that says that there are no boards available.

41
00:03:23,760 --> 00:03:25,150
This one here, this is TextView.

42
00:03:26,370 --> 00:03:27,870
No boards are available.

43
00:03:28,290 --> 00:03:30,750
Should be set to visible.

44
00:03:32,940 --> 00:03:39,540
So this function will just take care of creating the boards in the why it's you guys going to actually

45
00:03:39,540 --> 00:03:40,470
download it, right?

46
00:03:40,860 --> 00:03:45,480
Because we will download it somewhere else, then we will pass it to this function and this function

47
00:03:45,480 --> 00:03:48,230
will then go ahead and display everything in the UI.

48
00:03:49,100 --> 00:03:58,320
OK, now I want to make a little change in my boards because the board doesn't know about his I.D.,

49
00:03:58,710 --> 00:04:09,750
so I'm going to create a new variable here, VUL document I.D., which is a string, and then we of

50
00:04:09,750 --> 00:04:12,840
course need to add that here as well.

51
00:04:12,840 --> 00:04:15,270
So parcel restring.

52
00:04:17,769 --> 00:04:25,390
Then further down here, Passell right string with the document ID.

53
00:04:28,320 --> 00:04:29,730
OK, then, in the constant.

54
00:04:30,980 --> 00:04:35,720
I will also use this assigned to so I'm going to create a assigned to.

55
00:04:37,800 --> 00:04:38,420
Horrible.

56
00:04:39,150 --> 00:04:41,640
And my utils constant.

57
00:04:42,970 --> 00:04:46,910
So here we have the mobile with the name The Image Debord's Everything.

58
00:04:47,200 --> 00:04:51,040
Now let's create one for our assigned to.

59
00:04:51,170 --> 00:04:59,950
OK, uh, signed two, which will be a string, which will just have this text called Assigns to.

60
00:05:02,680 --> 00:05:07,870
Because now we can use this constant instead of using the string, which will be a magical string,

61
00:05:07,870 --> 00:05:12,910
and it's always difficult to then find the right spot where we use that string and how we called it.

62
00:05:12,910 --> 00:05:16,570
And if we made a mistake, then it's going to be difficult to find that mistake.

63
00:05:16,600 --> 00:05:22,960
So it's really a lot easier when you just work with constants that you can then quite easily adjust.

64
00:05:23,290 --> 00:05:23,820
All right.

65
00:05:24,280 --> 00:05:30,130
So now we can go to our Firestar class, because now it's actually time to get the boards list from

66
00:05:30,130 --> 00:05:32,590
our fire store database.

67
00:05:33,130 --> 00:05:35,740
So let's go ahead and create a new function here.

68
00:05:38,270 --> 00:05:41,520
So here we created the boards that we obtained user profile.

69
00:05:41,540 --> 00:05:50,480
Well, let's create a function to get the boards a list and we need to get the main activity as the

70
00:05:50,480 --> 00:05:52,100
activity that calls this function.

71
00:05:53,130 --> 00:06:03,060
Then I'm going to use this collection stuff as well, so am fire store collection with the constants

72
00:06:03,990 --> 00:06:06,860
dot boards then.

73
00:06:07,860 --> 00:06:10,070
Now we're using queries.

74
00:06:10,080 --> 00:06:15,690
So that is something that is pretty powerful and that is a feature that Firestone offers that unfortunately

75
00:06:16,140 --> 00:06:20,850
the real time database of Firebase doesn't offer.

76
00:06:21,360 --> 00:06:24,120
And that's really where the power of our store lies.

77
00:06:24,210 --> 00:06:25,200
That's why we use it.

78
00:06:25,570 --> 00:06:31,200
OK, I thought about using a database or a real time database and I even tried to build it there.

79
00:06:31,530 --> 00:06:33,470
But man, oh, man, that was a tough one.

80
00:06:33,480 --> 00:06:40,020
It really made things so much more difficult when you wanted to create a maintainable and hugely flexible

81
00:06:40,470 --> 00:06:41,670
database structure.

82
00:06:41,970 --> 00:06:42,710
That was a pain.

83
00:06:43,110 --> 00:06:45,960
So I decided to go with the fire store approach.

84
00:06:45,960 --> 00:06:52,710
And this is why pretty much all the stuff that we're going to do now is really a big part of why I decided

85
00:06:52,710 --> 00:06:53,790
to use the fire storm.

86
00:06:54,240 --> 00:07:05,640
So we are checking what the array contains, constants that assigned to and what is it designed to?

87
00:07:05,820 --> 00:07:08,040
Well, our current user ID.

88
00:07:09,240 --> 00:07:15,870
So current user, actually, we need to get it right, get current user I.D., this one.

89
00:07:17,150 --> 00:07:19,610
OK, so what we're doing is we're checking.

90
00:07:22,020 --> 00:07:27,540
The board's collection where the value for assigned to is the current user idee.

91
00:07:29,360 --> 00:07:35,420
So if we look at our boards here, for example, this board was created by this user and that's the

92
00:07:35,420 --> 00:07:41,230
user ID of the current user ID or the current user that is locked in the secure and user ID.

93
00:07:41,780 --> 00:07:48,020
So we just checked through all of the boards that we have were assigned to is equal to whatever, just

94
00:07:48,170 --> 00:07:49,940
ideas that we have.

95
00:07:50,950 --> 00:07:56,750
And if it's the same, then we want to display this board because then we want to use this board and

96
00:07:56,750 --> 00:07:57,730
it was assigned to us.

97
00:07:57,740 --> 00:08:02,870
So either we created it ourselves, so it's assigned to us or somebody else created it and assigned

98
00:08:02,870 --> 00:08:03,440
it to us.

99
00:08:03,770 --> 00:08:09,170
Then we also want to see this board, because then we need to make adjustments on the board maybe,

100
00:08:09,170 --> 00:08:10,910
or we need to finish tasks.

101
00:08:10,910 --> 00:08:13,880
And this project is also assigned to us and so forth.

102
00:08:15,780 --> 00:08:17,280
So what do we want to do with that?

103
00:08:17,310 --> 00:08:23,870
Well, we want to get it, so get and then that's add on success listener.

104
00:08:23,880 --> 00:08:28,950
So if that was successful then we will get and you can see there are multiple different options.

105
00:08:29,280 --> 00:08:31,620
What we will get and I'm just going to get a document.

106
00:08:32,760 --> 00:08:36,510
OK, so I'm just going to say, OK, now that you give me this document, let's use it.

107
00:08:36,750 --> 00:08:39,450
And I'm just going to write a little lock entry here.

108
00:08:40,620 --> 00:08:44,850
So simple document documents to string.

109
00:08:44,860 --> 00:08:52,290
So I'm just going to display the whole document as well as I will create a boards list.

110
00:08:54,460 --> 00:08:57,190
Which will be an array list of Borz.

111
00:08:59,820 --> 00:09:07,530
Which will be for now, an empty array list and of course, I want to add all of the words from that

112
00:09:07,530 --> 00:09:08,280
document to it.

113
00:09:09,000 --> 00:09:15,650
OK, so this document is a snapshot and the snapshot only contains the stuff that is assigned to us.

114
00:09:15,660 --> 00:09:17,470
So only the boards that are assigned to us.

115
00:09:17,850 --> 00:09:20,970
So what I can now do is I can go through the whole document.

116
00:09:24,780 --> 00:09:32,370
And then had every single board to my board list, so what I'm going to do is I'm going to say, OK,

117
00:09:32,370 --> 00:09:35,700
create a board, which is I to object.

118
00:09:36,450 --> 00:09:40,400
And here is our port call and column class, not Java.

119
00:09:40,950 --> 00:09:48,120
So we're basically saying whatever object you have there now, create a board object from it and stored

120
00:09:48,120 --> 00:09:58,930
in this board variable, which we then can use to, first of all, get the idea of that board.

121
00:10:00,180 --> 00:10:08,310
So now we don't only get the board list, but we are also getting the document ID of the board and we

122
00:10:08,310 --> 00:10:12,240
can now go ahead and add that board's list.

123
00:10:14,170 --> 00:10:18,610
Or the board to the board's list now, as it seems, the document idee.

124
00:10:20,540 --> 00:10:23,540
String, let's have a look what the problem is.

125
00:10:25,900 --> 00:10:32,660
Well, it has to do with two objects returning a nullable, these are the tricky ones, right?

126
00:10:32,680 --> 00:10:34,170
So it returns on nullable.

127
00:10:34,180 --> 00:10:35,530
That's why we need to.

128
00:10:37,620 --> 00:10:41,110
Use double exclamation marks here and here.

129
00:10:41,160 --> 00:10:47,190
Still getting a little error, that's because my document I.D. is a var or should be a var instead of

130
00:10:47,190 --> 00:10:52,410
a because I want to be able to change the document ID, as you can see.

131
00:10:53,010 --> 00:10:55,830
So what we do here and that's why I needed to change it real quick.

132
00:10:57,760 --> 00:11:01,780
OK, so at this point, we get the whole list, but what should we do now?

133
00:11:02,170 --> 00:11:07,270
Well, we should, of course, also populate our activity.

134
00:11:07,600 --> 00:11:14,200
So activity that populate the boards list to UI with the boards listed, we just prepare.

135
00:11:15,440 --> 00:11:19,100
OK, so that's what the whole Paulista UI function was for.

136
00:11:19,760 --> 00:11:25,640
It needed a shortlist to then display the board's list in our recent review.

137
00:11:26,060 --> 00:11:28,310
So that was the whole point of this function.

138
00:11:28,310 --> 00:11:34,900
And then we created this function to get the board's list, to then populate our board with it.

139
00:11:35,330 --> 00:11:37,160
So that's the add on success listener.

140
00:11:37,190 --> 00:11:44,690
Now, let's add in failure listener as well, and which I'm just going to highlight the progress dialogue.

141
00:11:45,040 --> 00:11:49,470
So here at Unfilial Listener, with an exception here called E!

142
00:11:49,880 --> 00:11:53,390
And I'm just going to say log E, simple name error while creating a board.

143
00:11:56,860 --> 00:12:02,090
All right, the next step that I'm going to do is also a little optimization step, so to speak.

144
00:12:02,620 --> 00:12:06,610
So let's go to the last user data function.

145
00:12:06,610 --> 00:12:09,630
So we have this function here, load user data.

146
00:12:11,500 --> 00:12:12,220
This one here.

147
00:12:12,790 --> 00:12:15,600
What I'm going to do is I'm going to add a parameter here.

148
00:12:16,060 --> 00:12:21,500
So that's going to be called Read Bords List, which will be a boolean.

149
00:12:23,560 --> 00:12:23,940
All right.

150
00:12:23,950 --> 00:12:28,080
So I want to know if I should read the board's list or I shouldn't.

151
00:12:28,660 --> 00:12:35,620
And this will be relevant here in the updated navigation user detail, because I want to make sure that

152
00:12:35,620 --> 00:12:43,330
I only update their navigation user details and only read the boards in there if necessary.

153
00:12:44,410 --> 00:12:47,470
OK, so let's go to our update, navigation user details.

154
00:12:48,820 --> 00:12:56,320
And actually, before we do that, real quick, I'm going to assign faults to this value, so not here,

155
00:12:56,620 --> 00:13:01,050
but here, I'm going to assign default faults.

156
00:13:01,180 --> 00:13:04,090
So this will be by default faults.

157
00:13:04,120 --> 00:13:10,270
So you don't always have to add a value, but if you add one, then you can make changes to it.

158
00:13:10,800 --> 00:13:11,290
OK.

159
00:13:13,440 --> 00:13:22,310
So now let's go over to our update navigation user detail, and here we need to accept a boolean and

160
00:13:22,320 --> 00:13:26,190
I'm going to give it the same name will be a Boolean.

161
00:13:30,820 --> 00:13:37,840
The idea behind this is that we don't always load everything from scratch, but, yeah, sometimes we

162
00:13:37,840 --> 00:13:40,190
just have to clean up things, right.

163
00:13:42,330 --> 00:13:47,910
OK, so before we update this function, I want to make clear why we even need that.

164
00:13:48,480 --> 00:13:54,250
So inside of our main activity in the uncreate, we load the user data.

165
00:13:54,280 --> 00:13:54,570
All right.

166
00:13:54,570 --> 00:13:56,820
So here first, our class load user data.

167
00:13:57,210 --> 00:14:05,580
At this point, we want to also load the ports so the user comes to the main activity for the first

168
00:14:05,580 --> 00:14:08,800
time and then we want to load all of the boards of that user.

169
00:14:09,000 --> 00:14:10,260
So here we need to pass in.

170
00:14:10,260 --> 00:14:15,410
True, because load user data is the function where we load the user data.

171
00:14:15,480 --> 00:14:15,840
Right.

172
00:14:15,870 --> 00:14:22,570
So it reads the board list or should it read the boards list boolean true or false.

173
00:14:22,590 --> 00:14:24,140
Well, I say yes, please read it.

174
00:14:24,840 --> 00:14:25,440
So then.

175
00:14:26,930 --> 00:14:32,810
It should read it when we loaded the first time, but now let's say the user has this work, this flow,

176
00:14:33,140 --> 00:14:36,630
so he comes to the app and he sees all of his elements here.

177
00:14:36,950 --> 00:14:42,260
Then he goes to the profile, he changes something in the profile and he comes back to this activity.

178
00:14:42,590 --> 00:14:45,560
Then I don't want him to load the whole board.

179
00:14:45,560 --> 00:14:48,920
Once again, the board can stay the same as it was before.

180
00:14:49,430 --> 00:14:53,950
The page will load, but it will not load all of the details of the boards.

181
00:14:53,960 --> 00:14:56,600
It will just keep the boards as they were before.

182
00:14:57,820 --> 00:15:02,620
All right, so this is just a design decision, you could have left that out, but it wouldn't be that

183
00:15:02,620 --> 00:15:03,490
optimized done.

184
00:15:06,030 --> 00:15:09,000
OK, and now we can go back to our update.

185
00:15:10,030 --> 00:15:13,150
Navigation user details.

186
00:15:14,070 --> 00:15:14,970
And here.

187
00:15:15,970 --> 00:15:28,240
I want to load the board's list if the rewards list is set to true, so if reports list said true,

188
00:15:28,690 --> 00:15:31,450
then go ahead and show the progress dialogue.

189
00:15:32,700 --> 00:15:40,170
That we have prepared so far, which is this please wait, progress dialogue, so here you can use resources,

190
00:15:40,170 --> 00:15:42,200
get string or string, please wait.

191
00:15:42,840 --> 00:15:51,180
And then our fire class get more list with this activity.

192
00:15:52,390 --> 00:15:55,290
And at this point, we can finally test our application.

193
00:15:58,410 --> 00:15:59,280
All right, so.

194
00:16:00,380 --> 00:16:01,310
Pro gymnast.

195
00:16:04,380 --> 00:16:05,550
No boats are available.

196
00:16:06,740 --> 00:16:11,810
And then it loads a lot someone, as you can see here, bought with image and bought without image.

197
00:16:13,400 --> 00:16:17,660
OK, so these are our boards were created earlier on.

198
00:16:19,690 --> 00:16:23,800
Now, there is one thing that I'm not so happy about, and that is the fact that I cannot distinguish

199
00:16:23,800 --> 00:16:28,570
the two boards from each other or where one ends and the other starts and so forth.

200
00:16:28,840 --> 00:16:32,080
So we should go back to our resources.

201
00:16:32,740 --> 00:16:37,060
And here we have the layout item board.

202
00:16:37,450 --> 00:16:41,620
And at the very bottom, I want to add something.

203
00:16:41,620 --> 00:16:48,640
So it's just inside of the last linear layout, which is just a little separator.

204
00:16:48,910 --> 00:16:49,490
All right.

205
00:16:49,510 --> 00:16:52,990
So width should be match parent and height will be.

206
00:16:54,480 --> 00:17:00,440
The item poorer on board divider height.

207
00:17:00,870 --> 00:17:02,790
All right, then.

208
00:17:03,780 --> 00:17:15,880
The margin top, so here margin top should be the wider margin top.

209
00:17:16,680 --> 00:17:23,099
And then finally, I want to have a little background, which will be at colors, divide or color.

210
00:17:23,950 --> 00:17:30,600
So it's this divided color that we prepared to grayish, whitish color, so slightly different than

211
00:17:30,600 --> 00:17:30,930
white.

212
00:17:31,940 --> 00:17:34,720
OK, so let's close this and run this again.

213
00:17:36,430 --> 00:17:42,740
All right, and so there's this little line here, barely visible, but it's there and that is just

214
00:17:42,740 --> 00:17:43,350
the watercolor.

215
00:17:43,360 --> 00:17:45,130
Of course, you could make it more grey.

216
00:17:45,130 --> 00:17:51,190
So it's a little more visible, but it is all design choice that you can make yourself OK.

217
00:17:51,220 --> 00:17:52,630
So that is it for this video.

218
00:17:52,690 --> 00:17:53,650
See you in the next one.

