1
00:00:00,150 --> 00:00:05,710
High students in this year all we're going to go ahead and create another Android application.

2
00:00:05,730 --> 00:00:10,920
So just click on the start of your android studio project and then for the application name just a in

3
00:00:10,920 --> 00:00:18,780
here at 69 and then here you can specify the company domain package name and project location and initially

4
00:00:18,830 --> 00:00:27,480
connect and he has choose API 16 Android 4.1 Jelly Bean for a minimum SDK and then click Next on here

5
00:00:27,510 --> 00:00:29,840
choose the activity next.

6
00:00:30,000 --> 00:00:35,470
And here you can specify the activity name and lay out the names so just leave it as default and then

7
00:00:35,550 --> 00:00:36,550
we can finish.

8
00:00:36,630 --> 00:00:39,560
So here as you can see our project is created.

9
00:00:39,690 --> 00:00:45,570
So now let's actually connect our application to the so it's at the top just click on Tools and then

10
00:00:45,570 --> 00:00:47,340
click on firebase.

11
00:00:47,330 --> 00:00:51,370
And now it's going to actually open the firebase assistant here for us.

12
00:00:51,480 --> 00:00:57,900
And then here click on storage or click on our realtime database excuse me realtime database and then

13
00:00:57,960 --> 00:01:00,260
we can save and retrieve data.

14
00:01:00,880 --> 00:01:04,480
Did that here click on Connect to firebase.

15
00:01:04,610 --> 00:01:08,090
So it's going to actually open the starting next day like for us.

16
00:01:08,090 --> 00:01:15,530
So let's wait a little bit here and now I want to actually connect my application to an already created

17
00:01:15,530 --> 00:01:17,160
Project in firebase.

18
00:01:17,270 --> 00:01:21,430
So choose this option choose an existing firebase or Google project.

19
00:01:21,590 --> 00:01:26,850
Just check this a radio button here and now select apps 65.

20
00:01:26,930 --> 00:01:27,520
Right.

21
00:01:27,530 --> 00:01:33,550
I want to actually connect my application to 65 and then click on Connect to firebase.

22
00:01:33,630 --> 00:01:39,610
And now as you can see here it's this firebase product creators and connected locally to module app.

23
00:01:39,830 --> 00:01:43,740
And we need to do the second step here at the realtime database to add up.

24
00:01:43,880 --> 00:01:47,250
So just click on this button at the realtime database to your app.

25
00:01:47,390 --> 00:01:49,910
And now we need to actually accept changes.

26
00:01:49,920 --> 00:01:52,250
For just click on this button accept changes.

27
00:01:52,550 --> 00:01:55,200
So it's going actually to something here.

28
00:01:55,370 --> 00:02:00,410
So let's actually wait a little bit here and now as you can see here everything is ready.

29
00:02:00,650 --> 00:02:06,080
So now let's actually go to our activity underlaid minute example here.

30
00:02:06,110 --> 00:02:12,950
So let's actually delete this hello world takes you here and now it's actually inside this pallet section

31
00:02:12,970 --> 00:02:14,480
this scroll down here.

32
00:02:14,630 --> 00:02:19,110
And this actually drag on recycling you into into our project.

33
00:02:19,250 --> 00:02:24,920
So here when I actually select this recycle view it can actually open the dialogue for us and it says

34
00:02:25,250 --> 00:02:32,720
add project dependency and it says this operation requires the library recycle you receive it.

35
00:02:32,720 --> 00:02:34,910
Would you like to add this library now.

36
00:02:34,910 --> 00:02:35,650
Yes.

37
00:02:35,750 --> 00:02:38,460
Just click on OK.

38
00:02:38,610 --> 00:02:42,960
So it's going to actually add recycle of dependency to our application.

39
00:02:42,990 --> 00:02:44,160
So it is very important.

40
00:02:44,190 --> 00:02:44,950
Right.

41
00:02:44,970 --> 00:02:48,860
So let's wait a little bit here and now as you can see here everything is ready.

42
00:02:48,870 --> 00:02:51,380
So again I have this rendering problem.

43
00:02:51,510 --> 00:02:57,540
So I told you in the previous tutorials in order to solve this problem you just literally can build

44
00:02:57,540 --> 00:02:58,380
at the top.

45
00:02:58,620 --> 00:03:02,410
And here you can either click on the project or rebuild project.

46
00:03:02,400 --> 00:03:05,350
So this time I choose this one rebuild project.

47
00:03:05,460 --> 00:03:07,330
So let's wait a little bit here.

48
00:03:07,560 --> 00:03:12,460
And the difference between a clean project and the liberal project is that the clean project is going

49
00:03:12,460 --> 00:03:18,300
to just clean your project and rebuild project is going to first clean your project and then it's going

50
00:03:18,300 --> 00:03:20,290
to actually build your project right.

51
00:03:20,310 --> 00:03:26,920
So it's much better to use the liberal project now as you can see where the errors are gone.

52
00:03:26,940 --> 00:03:33,960
So now it's actually just at the top click on View and then through windows and then click on Project.

53
00:03:34,090 --> 00:03:36,680
And now as you can see here we have this android view here.

54
00:03:36,690 --> 00:03:37,200
Right.

55
00:03:37,380 --> 00:03:41,670
So here at the bottom we have this great script so just open the screen.

56
00:03:41,680 --> 00:03:46,830
Great telescopes here and now we have the build that great project.

57
00:03:46,830 --> 00:03:52,570
So this is the project level builder cradle and we have the applet will build that great.

58
00:03:52,710 --> 00:03:56,700
So this one level build that cradle.

59
00:03:56,700 --> 00:04:01,560
And here we have these dependences block and here as you can see we have this right.

60
00:04:01,590 --> 00:04:09,300
So again we have this same error and because I am using the AP I-24 here it actually puts the AP 25

61
00:04:09,390 --> 00:04:10,620
right 25.

62
00:04:10,680 --> 00:04:12,750
So change this 25 to 24.

63
00:04:12,750 --> 00:04:17,580
If you are using the AP 24 so now let me show you the Android studio again.

64
00:04:17,580 --> 00:04:23,810
So Android studio at the top just click on Android studio and then here click on preferences.

65
00:04:23,910 --> 00:04:28,020
So if you are using a match you need to click on Android studio and then click on preferences and if

66
00:04:28,020 --> 00:04:32,870
you are using a Windows machine you need to click on file and then click on preferences or settings.

67
00:04:32,880 --> 00:04:38,220
So here just click on preferences and now I want to show you the assistant manager so here just opened

68
00:04:38,220 --> 00:04:45,240
this appearance and behavior and then opened the system settings and now just click on this Android

69
00:04:45,240 --> 00:04:49,430
SDK here and at the bottom click launch standalone SDK manager.

70
00:04:49,500 --> 00:04:52,290
So it's going to actually open the Android as the case manager for us.

71
00:04:52,290 --> 00:05:00,130
And as you can see here we have Android seven point one point one AP I-25 and we have Andrii 7.0.

72
00:05:00,270 --> 00:05:03,920
So here are these calls we are using Android seven point zero.

73
00:05:04,050 --> 00:05:09,170
So if you are using Android 7 point 1.1 API 25 no problem.

74
00:05:09,180 --> 00:05:16,410
You can use API 25 or and here you can just actually naturally close the window.

75
00:05:16,440 --> 00:05:19,120
You can just use that 25 right.

76
00:05:19,140 --> 00:05:26,430
If you are using API 25 but here because I am using Android 7 API 24 I need to change the value to 24

77
00:05:26,700 --> 00:05:28,490
right in order to solve this problem.

78
00:05:28,620 --> 00:05:29,810
So this is very important.

79
00:05:29,940 --> 00:05:32,130
And then at the top I need to click on scene now.

80
00:05:32,160 --> 00:05:34,220
So now the problem is solved.

81
00:05:34,230 --> 00:05:42,190
So here we need to actually add another dependency here and that dependency is firebase database UI.

82
00:05:42,210 --> 00:05:43,310
This is very important.

83
00:05:43,470 --> 00:05:46,520
So now that you actually open the web browser.

84
00:05:46,590 --> 00:05:51,590
So as you can see here this is my web browser and I actually entered this you all get hopped at Camp

85
00:05:51,600 --> 00:05:54,850
slash firebase slash firebase you Idas Android.

86
00:05:54,870 --> 00:06:00,430
So now let me actually just as you can see here it says table of contents and installation.

87
00:06:00,570 --> 00:06:05,970
So here we have this installation and now we need to actually add this dependency to our application

88
00:06:06,000 --> 00:06:08,780
and it says firebase UI database only.

89
00:06:08,880 --> 00:06:14,050
So just copy this code here right click on it and then click on copy and let's go to Android studio

90
00:06:14,400 --> 00:06:18,540
and here it says this dependency to Apple will be that great.

91
00:06:18,550 --> 00:06:19,150
Right.

92
00:06:19,170 --> 00:06:23,830
So here these are applicable bill that graden And here we have these dependences block.

93
00:06:24,000 --> 00:06:29,550
So just paste this cord here inside these dependencies plug plug into the scene now.

94
00:06:29,580 --> 00:06:32,020
And now its going to try to synch our project.

95
00:06:32,170 --> 00:06:37,050
And as you can see here at the bottom it says a refreshing firebase state so we should wait a little

96
00:06:37,050 --> 00:06:37,810
bit here.

97
00:06:37,830 --> 00:06:39,600
So now our project is ready.

98
00:06:39,780 --> 00:06:42,610
So lets go to I underline minute example here.

99
00:06:42,610 --> 00:06:46,350
Let me ask you the DoubleClick is stop in order to make this area wider.

100
00:06:46,440 --> 00:06:51,740
Now as you can see first of all let's actually click on this activity underly I mean they seem at here

101
00:06:51,780 --> 00:06:54,970
inside these componentry section it says Relatively out.

102
00:06:54,990 --> 00:07:01,760
So at the bottom click on text tab here here and then change this relatively to linear layout.

103
00:07:02,130 --> 00:07:06,830
Now we need to actually specify the orientation of our really linearly out.

104
00:07:06,840 --> 00:07:12,090
So here just type in orientation and now the autocomplete feature of Android studio is going to help

105
00:07:12,090 --> 00:07:16,140
you to choose this attribute Android called Call and orientation.

106
00:07:16,140 --> 00:07:23,760
So and then press on into your keyboard and choose vertical and actually switch to design at the bottom.

107
00:07:23,940 --> 00:07:28,230
Here let's actually as you can see if you have this custom for their app compact right.

108
00:07:28,300 --> 00:07:35,290
This actually again tried this recycled view into our Linnea lay out where the card so here this is

109
00:07:35,290 --> 00:07:36,960
our recycled review.

110
00:07:37,140 --> 00:07:46,420
So they are selected and for the ID just type in here recycler you and then a and entity on your keyboard.

111
00:07:46,420 --> 00:07:54,160
So now let's actually go to our main activity here and now first of we need to actually create some

112
00:07:54,250 --> 00:07:57,210
valuables inside our domain with the class.

113
00:07:57,220 --> 00:08:00,640
So here let's create a boxer class.

114
00:08:00,640 --> 00:08:07,110
So now let me just at the top click on view to Windows and then click click on Project.

115
00:08:07,390 --> 00:08:13,690
So here we have this app and then double click on the Starfall there and here just open this package

116
00:08:14,170 --> 00:08:20,620
and select this package and then click on file at the top new file new and into the cantabile class

117
00:08:21,130 --> 00:08:24,490
and for the name of our class just type in here.

118
00:08:24,490 --> 00:08:27,220
Buxar identical.

119
00:08:27,250 --> 00:08:27,730
OK.

120
00:08:27,970 --> 00:08:33,480
So now we have this Buxar class and there isn't that I actually created these classes because of you

121
00:08:33,480 --> 00:08:37,090
are actually receiving Buxar objects from the server.

122
00:08:37,090 --> 00:08:39,220
So let me show you their web browser here.

123
00:08:39,250 --> 00:08:41,040
So this is our Web browser.

124
00:08:41,170 --> 00:08:44,800
And as you can see just click on go to concert at the top.

125
00:08:44,800 --> 00:08:51,550
And here I need to click on app 65 so you know that we actually connected our Android application to

126
00:08:51,550 --> 00:08:53,610
app 65 firebase project.

127
00:08:53,680 --> 00:08:58,160
So just click on I-65 here and then here click on database.

128
00:08:58,210 --> 00:09:02,580
So we should actually refresh the page in order to see this data.

129
00:09:02,590 --> 00:09:07,030
We can actually just select rules and then click on data again.

130
00:09:07,030 --> 00:09:10,360
Now as you can see we have these a box of objects here.

131
00:09:10,360 --> 00:09:11,070
Right.

132
00:09:11,080 --> 00:09:12,740
So let's go back to the studio.

133
00:09:13,000 --> 00:09:15,270
And as you can see we have a box or a name box.

134
00:09:15,310 --> 00:09:16,900
Punch power and punch speed.

135
00:09:17,050 --> 00:09:20,640
So these are the instance variables of our boxer class.

136
00:09:20,650 --> 00:09:28,630
So here I can't actually say private's screen box Boxer name semi-colon.

137
00:09:28,870 --> 00:09:32,350
Private int punch power

138
00:09:34,970 --> 00:09:43,800
semi-colon probably read in Punch speed punch speed semi-colon.

139
00:09:44,050 --> 00:09:48,180
So now are we to actually create an empty constructor here.

140
00:09:48,220 --> 00:09:49,540
So I just see it right here.

141
00:09:49,540 --> 00:09:56,770
And then you can generate and then click on constructor and here just click on this package in order

142
00:09:56,770 --> 00:10:00,230
to de-select all these instance variables and that really kind of.

143
00:10:00,730 --> 00:10:06,410
So here we have this empty constructor and we have another we need to actually create another constructed

144
00:10:06,430 --> 00:10:09,810
in order to initialize our instance variables.

145
00:10:09,820 --> 00:10:16,990
So here I just right click on this in say this class boxer generate and then click on constructor and

146
00:10:16,990 --> 00:10:20,970
just select all these instance variables and then click OK.

147
00:10:20,980 --> 00:10:26,340
So here we have this constructor that is actually initializing all these instance variables.

148
00:10:26,440 --> 00:10:32,650
So we need to actually create a getter methods in order to actually allow other classes to access the

149
00:10:32,650 --> 00:10:34,660
value of this instance variables.

150
00:10:34,750 --> 00:10:40,380
So as you can see here the access modifier of this instance variables is actually private.

151
00:10:40,450 --> 00:10:44,340
So we need to provide getters for instance variables here.

152
00:10:44,440 --> 00:10:50,500
So it actually can generate and then we can get here and then here select all these instance value events

153
00:10:50,530 --> 00:10:52,400
and then click on OK.

154
00:10:52,540 --> 00:10:54,310
So here we have these getters.

155
00:10:54,310 --> 00:10:54,970
Right.

156
00:10:55,120 --> 00:10:59,440
So now let's actually go to activity underlaid main and examine.

157
00:10:59,620 --> 00:11:05,370
And here I want to actually create a custom layout for each item for each item view.

158
00:11:05,500 --> 00:11:07,070
So let's see how we can do that.

159
00:11:07,120 --> 00:11:12,000
So now at the top just click on View and then tool windows and then project.

160
00:11:12,190 --> 00:11:18,310
Now Art just DoubleClick and the savez folder and then I will click and this layout for there just select

161
00:11:18,310 --> 00:11:19,090
display for that.

162
00:11:19,120 --> 00:11:21,410
And at the top click on File new.

163
00:11:21,550 --> 00:11:24,360
And now we want to actually create a layer of three source file.

164
00:11:24,520 --> 00:11:26,170
So just select this file here.

165
00:11:26,770 --> 00:11:32,780
And for the name just type in here custom underline row.

166
00:11:32,830 --> 00:11:36,890
So this is the name of our file and the root element is linear.

167
00:11:36,890 --> 00:11:42,150
Lay out the source that is main and the directory name is layout and then click on OK.

168
00:11:42,250 --> 00:11:44,040
So here we have this custom row.

169
00:11:44,110 --> 00:11:44,820
Right.

170
00:11:44,860 --> 00:11:50,260
And here inside this componentry section it says linearly Ellsworthy call if it is not linearly old

171
00:11:50,290 --> 00:11:56,050
we can just click on it takes it up here at the bottom and here you can actually change for example

172
00:11:56,050 --> 00:12:02,140
that the old name too linearly out and then remember that you must actually pro-white an attribute for

173
00:12:02,440 --> 00:12:04,170
orientation of your linearly.

174
00:12:04,180 --> 00:12:05,560
This is really important.

175
00:12:05,560 --> 00:12:13,150
So now I just need to click on this design tab here at the bottom and here let's actually first of all

176
00:12:13,210 --> 00:12:16,040
just selectees linearly out vertical here.

177
00:12:16,210 --> 00:12:19,490
Or you can actually see at the bottom Picante step here at the bottom.

178
00:12:19,780 --> 00:12:23,380
And here you can actually change the layout height to Lappe content.

179
00:12:23,380 --> 00:12:23,680
Right.

180
00:12:23,680 --> 00:12:29,340
Because this because this is actually going to be a custom roll we want to display height to be wrapped

181
00:12:29,350 --> 00:12:33,500
content because this is going to be only our row not our layout.

182
00:12:33,700 --> 00:12:37,240
And you can actually also change this attribute inside this design tab.

183
00:12:37,450 --> 00:12:41,630
And here you can't change the layout height to lap content.

184
00:12:41,950 --> 00:12:42,970
Right.

185
00:12:42,970 --> 00:12:48,820
So the layout is much apparent and the layout height of our linearly alphabetically is that content.

186
00:12:49,210 --> 00:12:54,160
And now let's actually tried a text view into this linearly as vertical.

187
00:12:54,160 --> 00:12:59,520
So inside these widgets folder just selectees takes a view and then put it here inside is linearly outwards

188
00:12:59,520 --> 00:13:03,240
the call all you can actually put it here inside this componentry section.

189
00:13:03,250 --> 00:13:06,310
And you can put it inside this linearly or two vertical.

190
00:13:06,650 --> 00:13:09,280
And let's actually isolate this text view.

191
00:13:09,400 --> 00:13:16,900
And for the idea to step in here takes the boxer takes the box name and that person into on your keyboard

192
00:13:17,530 --> 00:13:21,550
and let's write another text view into this linearly outway article.

193
00:13:21,550 --> 00:13:26,130
So inside these widgets folder to select this text and put it here below this takes you.

194
00:13:26,120 --> 00:13:27,990
And instead this linearly outwards.

195
00:13:28,750 --> 00:13:37,240
Just select this takes you here and afford the idea to step in here takes the punch power takes the

196
00:13:37,240 --> 00:13:41,990
punch power and then present energy on your keyboard.

197
00:13:42,250 --> 00:13:43,370
Now let's actually try.

198
00:13:43,420 --> 00:13:49,370
This takes you here to select the stakes and drag it here into this linearly I-30 can just select this

199
00:13:49,410 --> 00:13:57,010
text and for the idea just step in here takes the punch speed and in person enter here on your keyboard.

200
00:13:57,010 --> 00:14:02,620
So now let's actually go into our main activity that double file here and now let me actually double

201
00:14:02,620 --> 00:14:06,290
click on the spine in order to make this area wider.

202
00:14:06,340 --> 00:14:11,710
So inside this main activity class I'm going to paste in some lines of code and then I'm going to explain

203
00:14:11,710 --> 00:14:13,350
to you what's going on here.

204
00:14:13,360 --> 00:14:16,640
So as you can see these are the lines of code that I pasted here.

205
00:14:16,710 --> 00:14:20,410
Nilay number 13 as you can see we have this variable.

206
00:14:20,410 --> 00:14:25,450
I actually declare this valuable and the name of this valuable is database reference and the data type

207
00:14:25,450 --> 00:14:30,050
of this valuable is database reference and the access modifier is private.

208
00:14:30,340 --> 00:14:37,000
And here in line number 14 here we have this firebreak recycle or adapter which we get from the firebase

209
00:14:37,020 --> 00:14:38,170
set up as you are.

210
00:14:38,310 --> 00:14:44,510
And that's why we actually added that dependency to our application in order to use this class firebase

211
00:14:44,510 --> 00:14:46,090
recycling adapter.

212
00:14:46,110 --> 00:14:52,290
And here inside the angle brackets we need to specify two arguments the first argument is the type of

213
00:14:52,290 --> 00:14:54,790
the data that we want we get from the set.

214
00:14:54,800 --> 00:15:00,750
So the first one is the Boxer Boxer class and the second one is the view holder which is going to specify

215
00:15:00,750 --> 00:15:03,080
the view holder of each item.

216
00:15:03,120 --> 00:15:03,920
Right.

217
00:15:04,000 --> 00:15:06,810
So we're going to create this view that last year.

218
00:15:07,200 --> 00:15:09,270
And for now it is in red right.

219
00:15:09,270 --> 00:15:17,490
Because we haven't we have we don't have this view that A-class inside our project and the name of this

220
00:15:17,910 --> 00:15:22,260
variable is firebase recycle adapter a line number 15.

221
00:15:22,270 --> 00:15:28,620
We have another variable and it's access but the file is private the data type of this variable is recycled

222
00:15:28,660 --> 00:15:31,500
review and the name of this variable is recycling.

223
00:15:31,650 --> 00:15:37,050
So inside this uncreate Smurfette I want to initialize these variables so I'm going to paste in some

224
00:15:37,050 --> 00:15:41,160
lines of code here inside this uncreate method and then I'm going to explain to you what's going on

225
00:15:41,160 --> 00:15:41,520
here.

226
00:15:41,520 --> 00:15:44,920
So these are the lines of code that I pasted here.

227
00:15:45,160 --> 00:15:53,040
And in line number 26 here I am really to this recycle view that I have declared in line number 17.

228
00:15:53,040 --> 00:15:53,640
Right.

229
00:15:53,640 --> 00:15:59,070
So here I want to initialize this variable so the cycle of you assignment operator and I am referring

230
00:15:59,070 --> 00:16:01,990
to does a user interface component right.

231
00:16:02,040 --> 00:16:05,680
Recycle have you find you by ID or that Id dot.

232
00:16:05,740 --> 00:16:08,760
And as you can remember they recycle a view.

233
00:16:08,760 --> 00:16:13,130
We actually name this ID as a recycler of your not recycle view as you can see here.

234
00:16:13,140 --> 00:16:18,630
If I actually go to actually with the underline minute examine the idea of this recycle of is recycle

235
00:16:18,630 --> 00:16:19,380
are you.

236
00:16:19,410 --> 00:16:21,840
So let's go back to our main activity that jobs aren't here.

237
00:16:21,840 --> 00:16:24,930
I specified that be in line number 28.

238
00:16:24,930 --> 00:16:26,420
I am setting the layout manager.

239
00:16:26,430 --> 00:16:29,900
So this is very important recycled view that sets layout manager.

240
00:16:30,000 --> 00:16:34,470
And here I am actually creating a new instance of linear layout manager.

241
00:16:34,470 --> 00:16:35,220
Why.

242
00:16:35,220 --> 00:16:40,760
Because inside this activity underlaid minute example here we have this recycle view Enceladus linearly

243
00:16:40,770 --> 00:16:41,610
out.

244
00:16:41,640 --> 00:16:49,020
So in order to specify a layout manager of this recycle view you need to say that we have a linear layout

245
00:16:49,020 --> 00:16:55,320
manager and we pass this context to mean activity that this here to this instance here in line number

246
00:16:55,320 --> 00:16:56,180
15.

247
00:16:56,400 --> 00:17:01,170
As you can see in line number Fritzy if you have this line of code firebase database that get instance

248
00:17:01,170 --> 00:17:03,240
that said persistence enable true.

249
00:17:03,240 --> 00:17:07,680
So here I am enabling the offline capability of firebase.

250
00:17:07,920 --> 00:17:12,890
And here I am initializing this database reference database reference assignment operator firebase that

251
00:17:12,920 --> 00:17:19,080
objects that get instance that get reference in this way we can actually access to a reference the the

252
00:17:19,080 --> 00:17:23,290
firebase database instance and we can have a reference to that instance.

253
00:17:23,430 --> 00:17:25,460
So now let me show you the web browser.

254
00:17:25,600 --> 00:17:32,040
And as you can see here this is our firebase database instance and then we want to initialize our database

255
00:17:32,040 --> 00:17:34,520
reference we need to have a reference to this instance.

256
00:17:34,650 --> 00:17:41,220
So that's why I am saying get reference at a lower number first to 42 as you can see here we are.

257
00:17:41,230 --> 00:17:46,950
We want to actually again enable the offline capability of firebase So again we must put this line of

258
00:17:46,950 --> 00:17:49,620
code here database friends that keeps seemed true.

259
00:17:49,920 --> 00:17:57,870
So now here in as you can see we need to actually to initialize these valuable firebase the cycler adapter.

260
00:17:57,960 --> 00:18:00,210
But first Vinit to have a view there.

261
00:18:00,360 --> 00:18:02,460
So let's actually create and hold the class.

262
00:18:02,470 --> 00:18:04,080
Actually this is going to be an inner class.

263
00:18:04,080 --> 00:18:04,600
Right.

264
00:18:04,620 --> 00:18:10,150
So inside of the class and after the end in calibrates of this uncreate effort and before the end in

265
00:18:10,170 --> 00:18:13,770
calibrates of this class mean activity inside this class.

266
00:18:13,850 --> 00:18:19,150
I want to actually create our view that a class act is going to be an inner class.

267
00:18:19,200 --> 00:18:19,640
Right.

268
00:18:19,650 --> 00:18:26,560
So here I can say public static class public static class and the name of our class is view.

269
00:18:26,640 --> 00:18:27,610
All right.

270
00:18:27,720 --> 00:18:35,190
So if you hold there and this class is going to actually extend recycle or view that view they're right

271
00:18:35,490 --> 00:18:40,440
and that I need to open and close this class by using these curly braces and opening curly brace followed

272
00:18:40,440 --> 00:18:46,830
by closing curly brace and now of any to actually pro-white a constructor for this whole.

273
00:18:46,860 --> 00:18:52,890
So here I can't say public and the name of the constructor must be the same as the name of the class.

274
00:18:52,920 --> 00:19:00,150
So public view hall there and here as you can see I need to actually put a pair of Prentice's here and

275
00:19:00,150 --> 00:19:05,220
then I need to open and close this constructed by using these curly braces and the inside Apprentice's

276
00:19:05,460 --> 00:19:11,310
of this constructor because I want to initialize the constructor of the superclass when to actually

277
00:19:11,310 --> 00:19:16,730
put on an argument of type view and the name of this argument is item view.

278
00:19:16,800 --> 00:19:17,590
Right.

279
00:19:17,700 --> 00:19:24,640
So this is the view is actually the type of the argument and the item view is actually the name of this

280
00:19:24,660 --> 00:19:25,560
argument.

281
00:19:25,610 --> 00:19:28,170
And now let's go inside the constructor.

282
00:19:28,230 --> 00:19:31,180
First we need to initialize the constructor of the superclass.

283
00:19:31,260 --> 00:19:34,400
So super item view.

284
00:19:34,420 --> 00:19:35,850
So now we have no errors.

285
00:19:35,860 --> 00:19:41,920
And as I told you earlier in this teacherly or in this application we want to use our only out our only

286
00:19:41,920 --> 00:19:43,430
out for item view.

287
00:19:43,570 --> 00:19:43,840
Right.

288
00:19:43,840 --> 00:19:45,700
We created this custom row.

289
00:19:46,060 --> 00:19:50,390
And as you can see here we want to use this row inside our recycler view.

290
00:19:50,530 --> 00:19:55,920
So inside is a main activity class here first insight is in a class view holder.

291
00:19:55,920 --> 00:19:57,710
I'm going to actually declare some variables.

292
00:19:57,940 --> 00:20:11,850
So takes few takes the Buxar name takes the boxer name semicolon takes the view takes the box there

293
00:20:12,710 --> 00:20:21,500
takes the punch power takes the punch power semicolon takes view takes the punch spit takes the punch

294
00:20:22,740 --> 00:20:26,230
speed write semi-colon.

295
00:20:26,460 --> 00:20:27,890
So we have these valuables.

296
00:20:27,930 --> 00:20:33,810
So now let's actually initialize our valuable insight are constructed of this whole class.

297
00:20:33,810 --> 00:20:38,260
This is actually an inner class and I told you that for inner classes we use static keyword.

298
00:20:38,310 --> 00:20:39,130
Right.

299
00:20:39,690 --> 00:20:46,270
So now up here inside this custom row you can see that we have these tapes view here which is actually

300
00:20:46,290 --> 00:20:47,480
actually box or name.

301
00:20:47,730 --> 00:20:50,880
And the second one it's ID ECAC punch power.

302
00:20:50,880 --> 00:20:53,210
And the first part is actually the point speed.

303
00:20:53,340 --> 00:21:00,200
So this is going to be our Actually our all right our only out for the item view and inside an activity

304
00:21:00,210 --> 00:21:05,160
class and Enceladus are in a class of your Holder as you can see we actually declare these variables

305
00:21:05,210 --> 00:21:08,830
to the boxer or to the punch power and the expanse speed.

306
00:21:08,850 --> 00:21:12,900
So now let's go inside this constructor and initialize these variables.

307
00:21:12,970 --> 00:21:15,300
So the box or an assignment operator.

308
00:21:15,450 --> 00:21:22,170
And then I need to cast this object around to take the view object and here because these text views

309
00:21:22,410 --> 00:21:24,830
are going to be inside an item view.

310
00:21:24,900 --> 00:21:25,190
Right.

311
00:21:25,200 --> 00:21:32,550
We have this item in view from the constructor right here we just need to say item view dot find view

312
00:21:32,550 --> 00:21:42,930
by ID or thought Id dot takes the bulk surname semicolon and then here takes the punch power assignment

313
00:21:42,930 --> 00:21:52,140
operator and that I need to cestus object to a text object item view that find view by ID are but Id

314
00:21:52,260 --> 00:21:59,760
that takes the punch power semicolon and takes the punch speed assignment operator.

315
00:21:59,790 --> 00:22:07,770
And then I need to cast this object to a text view object item view that find view by ID are that Id

316
00:22:07,780 --> 00:22:11,270
dot takes the punch speed semicolon.

317
00:22:11,680 --> 00:22:18,510
So we declare and initialized these objects these valuables which are of type text view.

318
00:22:18,930 --> 00:22:22,300
And here let's actually pro-white another view.

319
00:22:22,390 --> 00:22:23,390
Another variable here.

320
00:22:23,390 --> 00:22:28,770
This actually the insight is in a class A holder and can actually create another invaluable so view

321
00:22:29,160 --> 00:22:31,810
and the name of this variable is you write semicolon.

322
00:22:32,090 --> 00:22:39,210
And now I want you to get the item view so that whenever we actually have access to an object of view

323
00:22:39,230 --> 00:22:43,680
holder we can actually access that item view so that we can actually make that if you are an unclick

324
00:22:43,680 --> 00:22:47,990
listener we can make that view a listener through the clicks of the user.

325
00:22:48,000 --> 00:22:52,010
So here I have a view assignment operator item view.

326
00:22:52,020 --> 00:22:56,120
So this item view is actually is actually the view of each cell.

327
00:22:56,400 --> 00:22:56,860
Right.

328
00:22:56,880 --> 00:22:58,830
So in this way we can have access.

329
00:22:58,830 --> 00:23:01,460
We can have access to the item view.

330
00:23:01,500 --> 00:23:04,510
So now let's actually go inside our uncreate Smurfette.

331
00:23:04,650 --> 00:23:09,160
And here we need to actually initialize our firebase recycle the data.

332
00:23:09,180 --> 00:23:09,840
Right.

333
00:23:09,870 --> 00:23:15,350
So here I can say firebase recycle adapter assignment operator new.

334
00:23:15,390 --> 00:23:19,490
We need to create a new instance of type firebase recycler adapter.

335
00:23:19,500 --> 00:23:24,630
So I just need to hold the shift key on my keyboard and then press until that key on my keyboard.

336
00:23:24,720 --> 00:23:29,220
And now the autocomplete feature of Android studio is going to help me to choose this option.

337
00:23:29,220 --> 00:23:30,910
Firebase recycle adapter.

338
00:23:31,140 --> 00:23:34,730
So the first option here and the person interviewing on your keyboard.

339
00:23:35,010 --> 00:23:40,740
And now the autocomplete feature actually helped us to automatically put these lines of code here.

340
00:23:40,740 --> 00:23:41,320
Right.

341
00:23:41,340 --> 00:23:48,710
So after the end in curly brace put a semicolon here and it was to provide some arguments for this construction

342
00:23:48,740 --> 00:23:50,930
of this firebase recycle adapter.

343
00:23:50,970 --> 00:23:53,330
So the first argument is actually the model class.

344
00:23:53,340 --> 00:23:55,930
So the model class you know is the Boxer class.

345
00:23:55,950 --> 00:23:56,560
Right.

346
00:23:56,940 --> 00:24:00,110
And there's such an argument as I can see is the model lay out.

347
00:24:00,330 --> 00:24:01,550
So we need to provide the lay out.

348
00:24:01,560 --> 00:24:07,580
So I told you that we have our own lay out in this application which is this one custom underlined row.

349
00:24:07,620 --> 00:24:10,850
So in this time I want to use this custom underline row.

350
00:24:10,890 --> 00:24:11,880
Right.

351
00:24:11,880 --> 00:24:17,080
And the first argument is going to be the view the class that we have here which is actually an inner

352
00:24:17,100 --> 00:24:23,240
class view holder and a fourth argument as you can see here is actually that database reference.

353
00:24:23,260 --> 00:24:26,920
So model class model lay out the whole class and reference.

354
00:24:26,970 --> 00:24:33,420
So the model class is actually the boxer class self self-taught class.

355
00:24:33,420 --> 00:24:36,560
So it may actually create a new life here comma.

356
00:24:36,780 --> 00:24:40,230
And the second argument is actually the model lay out.

357
00:24:40,260 --> 00:24:46,450
So here I told you that we have or only out custom on the underlying rules so here I can say our thoughts

358
00:24:47,550 --> 00:24:54,620
ID dot our DOT lay out dot custom arrow right.

359
00:24:54,780 --> 00:24:58,190
And then he had this is actually our only out right for each row.

360
00:24:58,620 --> 00:25:04,230
And for the first argument we need to pro-white the view hole there as you can see here we have this

361
00:25:04,230 --> 00:25:05,190
view holder class.

362
00:25:05,220 --> 00:25:06,790
Right this is actually an inner class.

363
00:25:06,810 --> 00:25:09,200
So here I can say a V hole there.

364
00:25:09,230 --> 00:25:12,360
But class comma.

365
00:25:12,480 --> 00:25:18,900
And for the final argument we need to actually refer to our database reference and now as you can see

366
00:25:18,900 --> 00:25:20,310
here we have no errors.

367
00:25:20,340 --> 00:25:22,720
We actually put all these arguments here.

368
00:25:22,890 --> 00:25:27,680
Right and now we can actually work on this populate view whole method.

369
00:25:27,810 --> 00:25:31,400
So let's actually go inside the curly braces of the Smurfette populated you Hodell.

370
00:25:31,780 --> 00:25:37,940
And now I want to actually get the boxer name punch power and punch speed right.

371
00:25:37,950 --> 00:25:40,700
So here I can see a real hole there.

372
00:25:40,710 --> 00:25:43,380
So as you can see we actually get this hole there from this.

373
00:25:43,450 --> 00:25:48,430
MF It is actually an argument of this if it is an object of this view holder.

374
00:25:48,520 --> 00:25:54,810
So when we actually refer to this object the constructed here is going to be called automatically.

375
00:25:54,930 --> 00:25:55,160
Right.

376
00:25:55,170 --> 00:25:57,590
And these variables are going to be initialized.

377
00:25:57,600 --> 00:26:04,410
So here we have you hold the dot and now we can access this very well so I can say if you hold that

378
00:26:04,410 --> 00:26:09,250
that takes the Buxar name dot set text right.

379
00:26:09,270 --> 00:26:12,090
And here we have this model which is a boxer.

380
00:26:12,240 --> 00:26:17,080
And here I can see a model that gets Buxar name right.

381
00:26:17,210 --> 00:26:22,670
And in this way we can actually to get a box of name and put it inside our recycle over you and each

382
00:26:22,670 --> 00:26:24,380
row has free text views right.

383
00:26:24,380 --> 00:26:26,700
For example the first one is that takes the box only.

384
00:26:26,840 --> 00:26:31,030
So in this way we can actually get the boxes going from the server and put it here.

385
00:26:31,370 --> 00:26:37,880
So let's go back to our main activity class and here view holder that takes the punch power that said

386
00:26:37,880 --> 00:26:49,820
text model that gets box set get punch power if you Holar that DXi punch speed that said text model

387
00:26:50,690 --> 00:26:59,390
that gets punched speed and now we can see that you have actually used these text reviews and we get

388
00:26:59,390 --> 00:27:00,500
these data from the server.

389
00:27:00,500 --> 00:27:07,610
So now up after the end in curly brace of this adapter we need to say that recycle view you right dot

390
00:27:07,670 --> 00:27:13,490
set it after we need to set the adapter for this recycler view and the adapter is firebase recycler

391
00:27:13,500 --> 00:27:14,100
adapter.

392
00:27:14,270 --> 00:27:15,940
So firebase the cycler adapter.

393
00:27:16,010 --> 00:27:16,950
This is very important.

394
00:27:16,970 --> 00:27:20,900
If you don't put this line of code here your application is not going to work.

395
00:27:21,170 --> 00:27:24,390
So let's actually run our application now.

396
00:27:24,500 --> 00:27:26,920
And here too is one of these virtual devices.

397
00:27:26,930 --> 00:27:27,910
And then click on OK.

398
00:27:27,920 --> 00:27:30,710
So as you can see here our application crashed.

399
00:27:30,710 --> 00:27:31,260
Right.

400
00:27:31,310 --> 00:27:36,370
So I told you in order to find out why your application crashed UNITA code translates to you and at

401
00:27:36,360 --> 00:27:38,510
about then click on Android monitor.

402
00:27:38,510 --> 00:27:39,060
Right.

403
00:27:39,230 --> 00:27:41,540
And then here we can actually find the error.

404
00:27:41,540 --> 00:27:46,760
So here let's actually scroll to the top and it says I told you to find the fatal exception here and

405
00:27:46,760 --> 00:27:47,650
it says Main.

406
00:27:47,690 --> 00:27:51,100
So this means that the error has occurred in say the main threat.

407
00:27:51,320 --> 00:27:59,090
And now here let's actually see the error and it says that on Android that content that the arrest that

408
00:27:59,090 --> 00:28:03,780
resource is not found exception stream resource ID right.

409
00:28:03,790 --> 00:28:08,480
And here we have these links so we can actually click on this link here.

410
00:28:08,480 --> 00:28:09,850
For example this one.

411
00:28:10,160 --> 00:28:12,750
And now it's actually called Android studio.

412
00:28:12,770 --> 00:28:14,780
And it says that the error occurred in this line.

413
00:28:15,050 --> 00:28:16,370
So we have another link.

414
00:28:16,400 --> 00:28:21,860
So we have this link here and it says that the error occurred in this line of code.

415
00:28:21,890 --> 00:28:29,210
So the first line which is actually a little bit more helpful right here it says that the error Error

416
00:28:29,250 --> 00:28:36,080
Occurred in this line of code and when the flow of our program breached to this line of code our program

417
00:28:36,080 --> 00:28:36,940
crashed.

418
00:28:36,950 --> 00:28:38,020
So why this happened.

419
00:28:38,040 --> 00:28:44,400
Can you figure out why this happened this happened because the punch power is actually an integer value.

420
00:28:44,660 --> 00:28:48,070
And this set takes Smurfit needs a strange value right.

421
00:28:48,080 --> 00:28:53,080
I told you in the adult section of the course that this text Nefert needs a string value.

422
00:28:53,090 --> 00:28:58,470
So here we I truly didn't convert this integer value to a string value.

423
00:28:58,490 --> 00:29:04,490
So in order to convert this value this integer value to a string value I just need to put a plus operator

424
00:29:04,490 --> 00:29:06,910
here and then I put two double quotes.

425
00:29:06,920 --> 00:29:12,140
So in this way we can actually convert this integer value to and twice think value.

426
00:29:12,140 --> 00:29:16,040
And here again we are getting this punch speed which is actually an integer value.

427
00:29:16,190 --> 00:29:23,000
And this text if it needs a single value so we need to change this value we need to convert this integer

428
00:29:23,000 --> 00:29:26,600
value to osting value by putting a plus operator and two that Alcott's.

429
00:29:26,600 --> 00:29:28,400
So let's look at our application again.

430
00:29:28,430 --> 00:29:32,240
So as you can see here our application is running on the simulator.

431
00:29:32,240 --> 00:29:35,060
And here we can see the data that we get from the server.

432
00:29:35,090 --> 00:29:36,840
So a 100 or 200.

433
00:29:36,870 --> 00:29:39,020
Now let me show you the web browser here.

434
00:29:39,110 --> 00:29:41,250
So let me show you the emulator.

435
00:29:41,310 --> 00:29:44,820
Now we can see that we have these objects right.

436
00:29:44,900 --> 00:29:48,700
And the name of the boxes is a the punch power is one handed.

437
00:29:48,710 --> 00:29:50,370
And the punch speed is 200.

438
00:29:50,480 --> 00:29:53,050
And we have another boxer right.

439
00:29:53,090 --> 00:29:57,980
And its name is be the punch power is 10 and the punch speed is 20.

440
00:29:57,980 --> 00:30:04,380
And it goes to the to that down as you can see here we can see all these other pucks that optics right

441
00:30:04,540 --> 00:30:04,800
now.

442
00:30:04,840 --> 00:30:09,090
I want to show you the unclick listener right how we can actually make these views for example that

443
00:30:09,090 --> 00:30:12,520
the user clicks on this item and we need to be.

444
00:30:12,560 --> 00:30:15,430
I want to be notified whenever the user clicks on the spot.

445
00:30:15,700 --> 00:30:19,400
This is me on this item view right on the set.

446
00:30:19,640 --> 00:30:24,510
So in order to do that let's go inside this populate view Holder's method.

447
00:30:24,890 --> 00:30:30,650
And here I can say as you can see if you get this view hold that right this view holder holds the value

448
00:30:30,860 --> 00:30:32,150
of this item.

449
00:30:32,150 --> 00:30:34,770
So now we have access to this view.

450
00:30:34,910 --> 00:30:38,960
So here I can easily say View hole there right.

451
00:30:39,090 --> 00:30:41,170
That view.

452
00:30:41,460 --> 00:30:43,900
So now we have access to that item view.

453
00:30:43,920 --> 00:30:44,270
Right.

454
00:30:44,280 --> 00:30:45,490
Let's scroll down here.

455
00:30:45,510 --> 00:30:51,600
As you can see I created this valuable view inside this Nicholasville holder and inside this constructor

456
00:30:51,870 --> 00:30:55,000
I am assigning this item view to this view.

457
00:30:55,080 --> 00:30:55,730
Right.

458
00:30:55,740 --> 00:30:57,970
And in this way we have access to this item view.

459
00:30:58,020 --> 00:31:03,030
So if I show you the emulator as you can see we have this item view right and we can make this item

460
00:31:03,030 --> 00:31:05,540
view a listener to the clicks of the user.

461
00:31:05,550 --> 00:31:09,770
So let's go back to our uncreate Meffert and insiders populate a view holder method.

462
00:31:09,780 --> 00:31:16,600
So you hold that view that set unclick listener right.

463
00:31:16,650 --> 00:31:19,550
And in this way we can actually make that view and unclick listener.

464
00:31:19,800 --> 00:31:27,940
And here I need to create an instance of type uncle in a Suneel view that unclick listener.

465
00:31:27,960 --> 00:31:28,850
Right.

466
00:31:29,380 --> 00:31:35,780
And now you can see that again we have actually an anonymous inner class and not anonymous in a class

467
00:31:35,780 --> 00:31:42,210
is actually conforming or implementing this unclick within an interface and that because that anonymous

468
00:31:42,230 --> 00:31:48,780
initialises is actually implementing this unclick is an interface that Cholas must provide an implementation

469
00:31:48,780 --> 00:31:50,020
for this method.

470
00:31:50,190 --> 00:31:57,090
So let's go inside this uncle my friend and here I can say for example TOSed that make text and for

471
00:31:57,090 --> 00:32:02,320
the first argument we need to provide the the context I mean activity that this comma.

472
00:32:02,490 --> 00:32:10,300
And for the second argument I can say that this item is clicked comma.

473
00:32:10,410 --> 00:32:17,070
And for the first argument we need to specify actually the length the duration that this host is going

474
00:32:17,070 --> 00:32:18,210
to be shown to the user.

475
00:32:18,330 --> 00:32:20,430
So you want to choose Shortland that's short.

476
00:32:20,460 --> 00:32:22,670
So host that line that short.

477
00:32:22,830 --> 00:32:27,440
And finally we need to call that show an effect on this object on this toast object.

478
00:32:27,450 --> 00:32:31,680
So now let me create a new line here so that you can see this toast object here better.

479
00:32:31,800 --> 00:32:34,590
So let's run our project now.

480
00:32:34,860 --> 00:32:36,220
Let me show you the emulator.

481
00:32:36,330 --> 00:32:38,680
And now as you can see we have these items.

482
00:32:38,850 --> 00:32:45,510
And let's actually click on this item here and it says this item is clicked or I can I can also get

483
00:32:45,510 --> 00:32:48,110
the position of this item as fast as you can see here.

484
00:32:48,240 --> 00:32:54,710
This populate the holder actually has an argument of type integer and its name is position.

485
00:32:54,720 --> 00:33:00,740
So here I can say this item is clicked right colon plus position.

486
00:33:01,170 --> 00:33:03,350
Let's run our project now.

487
00:33:03,450 --> 00:33:04,840
Let me show you the emulator.

488
00:33:08,130 --> 00:33:13,210
Let's click on one of these items and it says this item is CLEET zero.

489
00:33:13,340 --> 00:33:15,240
So the position of this item is zero.

490
00:33:15,260 --> 00:33:16,020
Right.

491
00:33:16,460 --> 00:33:18,850
And it says this this item booklet is free.

492
00:33:19,190 --> 00:33:22,880
And all these other budget optics right.

493
00:33:22,910 --> 00:33:27,830
So hopefully that makes sense and I think that's enough for this theater.

494
00:33:27,910 --> 00:33:32,620
Also if you have any questions about these concepts that I hurt you in this lesson please.

495
00:33:32,630 --> 00:33:34,010
What's the discussion in the course.

496
00:33:34,040 --> 00:33:35,920
I do my best to answer all of your questions.

497
00:33:36,080 --> 00:33:38,840
Thank you very much for watching and I'll see you in the next year Toria.

