1
00:00:00,690 --> 00:00:02,870
And then we have this do in background.

2
00:00:02,890 --> 00:00:04,340
This is really important.

3
00:00:04,590 --> 00:00:05,120
OK.

4
00:00:05,210 --> 00:00:10,790
Do it do in background so it's going to do the task of downloading data from the internet in the background

5
00:00:10,820 --> 00:00:11,030
it.

6
00:00:11,030 --> 00:00:11,310
OK.

7
00:00:11,310 --> 00:00:17,970
So that's why its name is in background and we have this argument Possum's but I'm sorry as you can

8
00:00:17,970 --> 00:00:27,920
see here at in line at 54 74 as you can see we have actually created an object of type stuff.

9
00:00:27,930 --> 00:00:34,650
So remember that because the output of this class this async class is going to be to use stuff the Smurfette

10
00:00:34,650 --> 00:00:39,120
doing background is going to return an object of type human stuff.

11
00:00:39,120 --> 00:00:45,180
So that's why we actually created an object of type items of stuff inside this method and the name of

12
00:00:45,180 --> 00:00:46,620
this object is iTunes stuff.

13
00:00:46,650 --> 00:00:48,890
Assignment operator new iTunes stuff.

14
00:00:48,900 --> 00:00:51,720
So now I have an object of type items and stuff.

15
00:00:51,960 --> 00:00:59,390
And I actually initialize this object here and in line 75 as you can see I created Avari habit of type

16
00:00:59,390 --> 00:01:04,930
strange an object of types think and the name of this value of the name of this variable is data.

17
00:01:04,950 --> 00:01:07,750
So here I want to actually initialize this data right.

18
00:01:07,770 --> 00:01:14,010
So here I actually created an object of of type items husht TTP client.

19
00:01:14,120 --> 00:01:21,520
So new client here is going to actually create an object of type items typically.

20
00:01:21,570 --> 00:01:21,950
OK.

21
00:01:22,050 --> 00:01:29,300
So here we have an object of type or this class item was likely to be client but get items stuff data.

22
00:01:29,310 --> 00:01:35,060
So remember in inside these items how she typically And here we have this Smurfette get items stuff

23
00:01:35,290 --> 00:01:40,800
up which is actually going on download the data from the Internet is going to connect to the Internet

24
00:01:40,830 --> 00:01:42,840
and then what those data are from the Internet.

25
00:01:43,050 --> 00:01:46,630
So that's the job of the Smif it get iTunes stuff data stream.

26
00:01:46,650 --> 00:01:50,890
But inside this main I keep class I am actually creating an object of type II.

27
00:01:50,900 --> 00:01:54,070
Humes husht stipulate this is actually an object.

28
00:01:54,070 --> 00:01:54,560
OK.

29
00:01:54,810 --> 00:01:58,010
And we are calling the Smurfette which is actually an instance method.

30
00:01:58,050 --> 00:02:00,950
OK this is not and this is actually not static.

31
00:02:01,140 --> 00:02:07,580
So we call this object on our Smurfette we are actually calling this method on an object of type.

32
00:02:07,690 --> 00:02:09,640
ITunes has typically OK.

33
00:02:10,050 --> 00:02:13,980
New items Hashid to be client that get iTunes stuff later.

34
00:02:14,190 --> 00:02:20,010
So its going to get that data and put those data inside this data are valuable here and here we have

35
00:02:20,010 --> 00:02:21,690
this try catch block.

36
00:02:22,170 --> 00:02:24,640
So try to use stuff.

37
00:02:24,690 --> 00:02:26,940
So he had referred to the name of this object.

38
00:02:26,970 --> 00:02:31,480
HUME stuff assignment operator Jason iTunes parser.

39
00:02:31,560 --> 00:02:37,560
So he had referred to the name of this class Jason iTunes part Parsa that I have in my project as you

40
00:02:37,560 --> 00:02:38,290
can see here.

41
00:02:38,490 --> 00:02:41,550
And we have this static method inside our class.

42
00:02:41,600 --> 00:02:43,430
Ok iTunes stuff.

43
00:02:43,680 --> 00:02:45,280
Get the iTunes stuff OK.

44
00:02:45,540 --> 00:02:50,760
So inside this main activity class I referred to the name of this place on iTunes parser class that

45
00:02:50,790 --> 00:02:53,110
get iTunes stuff later.

46
00:02:53,370 --> 00:02:59,460
So we passed this data to that to the Smurfette and then we are actually getting that data and we are

47
00:02:59,490 --> 00:03:02,940
actually putting that we are actually assigning that to the iTunes stuff later.

48
00:03:03,030 --> 00:03:09,390
So remember this method get iTunes stuff here is going to actually turn an object as you can see inside

49
00:03:09,390 --> 00:03:10,940
the states on iTunes sparser.

50
00:03:11,070 --> 00:03:17,310
This method is going to return an object of type iTunes sparser iTunes stuff as you can see here.

51
00:03:17,310 --> 00:03:23,670
So we are here we are actually signing that return value to these items stuff so we can do that because

52
00:03:24,000 --> 00:03:28,680
the Smurfette is going to return an object of type I stuff.

53
00:03:29,070 --> 00:03:33,960
By this argument as you can see here and then we can actually assign that value that returns value to

54
00:03:33,960 --> 00:03:38,400
these items stuff here which is again off of items stuff right.

55
00:03:38,760 --> 00:03:41,180
And some of it is going to actually accept r.

56
00:03:41,220 --> 00:03:47,670
And then its going to actually parse the values the day somebody is from the Internet and then its going

57
00:03:47,670 --> 00:03:49,680
to pretend that iTunes stuff object.

58
00:03:49,980 --> 00:03:52,440
So let's go back to our main activity that of a fight here.

59
00:03:52,440 --> 00:03:57,240
So now we have that data and now we have as you can see here we are actually assigning that data to

60
00:03:57,240 --> 00:03:58,340
these iTunes stuff.

61
00:03:58,620 --> 00:04:03,930
And then we are actually the initialising this I enjoy you Arel that I actually declared in our main

62
00:04:03,930 --> 00:04:07,120
activity class inside our main activity class here.

63
00:04:07,140 --> 00:04:11,850
I actually declared that these items are valuable which is strange.

64
00:04:11,980 --> 00:04:13,070
11:25.

65
00:04:13,260 --> 00:04:19,550
So here in Meffert in doing background I am I am actually instantiating this valuable.

66
00:04:19,740 --> 00:04:22,000
So I am sure you are an assignment operator.

67
00:04:22,120 --> 00:04:23,210
Items stuff.

68
00:04:23,220 --> 00:04:29,400
So here I referred to the name of this object use stuff that get artist view of it.

69
00:04:29,430 --> 00:04:32,890
So here I am actually getting the artist Gidding artist.

70
00:04:33,000 --> 00:04:37,420
You model that you are and that we can actually download from the internet.

71
00:04:37,680 --> 00:04:38,340
Okay.

72
00:04:38,790 --> 00:04:43,620
And here I am actually that you are that is going to actually allow us to download the image from the

73
00:04:43,620 --> 00:04:44,570
Internet right.

74
00:04:44,670 --> 00:04:47,430
And here I am assigning value to these to you all.

75
00:04:47,430 --> 00:04:55,700
So inside is adjacent iTunes of that class as you can see in line 28 I am getting disvalue art artwork

76
00:04:55,830 --> 00:04:58,620
out and 100 here from this artist object.

77
00:04:58,620 --> 00:05:04,440
So inside me an active I am actually signing that you are Ltds I am sure you are OK by calling items

78
00:05:04,500 --> 00:05:06,330
stuff that get artist view it.

79
00:05:06,400 --> 00:05:14,850
OK and that here that we have this I am gdel in line 81 I am instantiating the bitmap object that I

80
00:05:14,850 --> 00:05:18,320
again declared in line 27 inside our main activity class.

81
00:05:18,330 --> 00:05:18,970
OK.

82
00:05:19,200 --> 00:05:22,890
So here I am instantiating the speed map assignment operator.

83
00:05:22,920 --> 00:05:28,160
I actually created an object of type items hash TTP client.

84
00:05:28,440 --> 00:05:28,730
OK.

85
00:05:28,740 --> 00:05:33,710
As you can see here and here as you can see I am actually calling this method on this object.

86
00:05:33,710 --> 00:05:37,110
Get me get bitmapped from u r l i n g u r.

87
00:05:37,230 --> 00:05:42,540
Ok so here we are calling this method that is inside of these items how shitty because we have this

88
00:05:42,540 --> 00:05:43,160
method here.

89
00:05:43,170 --> 00:05:45,960
In order to download the image from the Internet right.

90
00:05:46,020 --> 00:05:51,570
So I just referred to the name of this method he had inside our main activity class and we are calling

91
00:05:51,570 --> 00:05:57,300
that Befort on this object new iTunes Hostettler client and here we are passing this on I am to you

92
00:05:57,300 --> 00:05:58,830
all here.

93
00:05:59,050 --> 00:06:07,090
And now as you can see here Insite is doing background Mefford I am actually using these new items husht

94
00:06:07,100 --> 00:06:09,040
typically in here two times.

95
00:06:09,090 --> 00:06:15,300
I actually I am actually creating this object two times in my method and I think that's not very good.

96
00:06:15,300 --> 00:06:17,700
That's not really good programming practice.

97
00:06:17,790 --> 00:06:23,960
I can actually create an object of type items how shitty the client and assign that object to a valuable

98
00:06:24,270 --> 00:06:26,990
and then I can actually use that valuable.

99
00:06:27,000 --> 00:06:30,340
So here let's actually create an object of type items.

100
00:06:30,340 --> 00:06:35,130
How should it be a client and the name of this object is going to be items how to be client assignment

101
00:06:35,130 --> 00:06:37,500
operator new iTunes.

102
00:06:37,500 --> 00:06:38,440
How typical are you.

103
00:06:38,490 --> 00:06:38,970
OK.

104
00:06:39,120 --> 00:06:41,860
And then I need to put a semicolon at the end of my statement.

105
00:06:41,910 --> 00:06:45,280
So as you can see here I am actually referring to this object.

106
00:06:45,280 --> 00:06:50,510
Look at here I am actually creating an object of type items such a typical.

107
00:06:50,670 --> 00:06:53,150
So I can't delete this piece of code here and there.

108
00:06:53,160 --> 00:06:57,710
I just referred to the name of this object that I created in line 76.

109
00:06:58,010 --> 00:06:58,450
OK.

110
00:06:58,520 --> 00:06:59,680
Items such a typical.

111
00:06:59,710 --> 00:07:04,280
So as you can see here I am actually creating an object of type I human typically.

112
00:07:04,390 --> 00:07:10,440
And I am assigning that value to this object to this object which is of type items I should decline

113
00:07:10,530 --> 00:07:11,360
this valuable.

114
00:07:11,580 --> 00:07:15,960
And now I can actually read through the name of this variable and call this method and again inside

115
00:07:15,960 --> 00:07:22,990
is Triple H as you can see again I am actually creating an order object of type items to shush the typical

116
00:07:22,990 --> 00:07:23,560
diet.

117
00:07:23,850 --> 00:07:31,440
I can actually use this object here is valuable here that I created inline Sixtus 76 so I can just delete

118
00:07:31,470 --> 00:07:35,300
this piece of code here and I can just type in iTunes.

119
00:07:35,310 --> 00:07:40,440
Hashi typically And as you can see here so this is a very good programming practice that I want to show

120
00:07:40,440 --> 00:07:40,840
you.

121
00:07:40,950 --> 00:07:44,450
So we were actually creating two objects of type.

122
00:07:44,500 --> 00:07:45,440
How should he be.

123
00:07:45,450 --> 00:07:51,600
How should he be client and now we have one object and we are using that object here and here in order

124
00:07:51,960 --> 00:07:54,760
to get that data and download the image from the Internet.

125
00:07:54,810 --> 00:08:00,780
So it has to be client that get treatment from you or I am to you are that as you can see here.

126
00:08:01,010 --> 00:08:01,850
OK.

127
00:08:01,950 --> 00:08:06,680
And by passing this I you are and here we are actually downloading that data from the Internet.

128
00:08:06,690 --> 00:08:10,540
And here I am assigning those data to that image to the speed map here.

129
00:08:10,680 --> 00:08:15,150
OK that's the task that is actually being done in the background.

130
00:08:15,270 --> 00:08:17,520
And here we had we have this catch block here.

131
00:08:17,640 --> 00:08:23,430
So in case some errors happen or we can actually we can't actually connect to the Internet.

132
00:08:23,640 --> 00:08:30,000
So it's going to actually put those errors the information about the errors in the log tedious print

133
00:08:30,090 --> 00:08:30,780
stack trace.

134
00:08:30,810 --> 00:08:35,710
And here we are actually returning to the iTunes stuff return iTunes stuff.

135
00:08:35,850 --> 00:08:40,880
So now I am actually returning the iTunes stuff from the Smurfette between background right.

136
00:08:41,310 --> 00:08:43,050
And we have this on post.

137
00:08:43,380 --> 00:08:46,710
So this is going to be executed on them Fred.

138
00:08:46,740 --> 00:08:52,310
So now we can actually get the information that we received as an argument of this on post executive

139
00:08:52,430 --> 00:08:55,740
Meffert and we can put those information on the for.

140
00:08:55,860 --> 00:08:56,960
So Unbossed thinks it cute.

141
00:08:57,000 --> 00:09:02,320
And then here in line one hundred and one you are calling it the supervision of the Smurfit Superlight

142
00:09:02,320 --> 00:09:05,320
on unposed to execute iTunes stuff.

143
00:09:05,460 --> 00:09:11,670
As you can see here and here as you can see I am actually just setting the text of this text the artist

144
00:09:11,670 --> 00:09:17,640
name that said text iTunes stuff that get artist name as you can see here we are actually receiving

145
00:09:17,790 --> 00:09:24,820
iTunes of stuff object as an argument so iTunes stuff that get artist name the type that said text iTunes

146
00:09:24,840 --> 00:09:31,160
stuff that get type the kind that said text iTunes stuff that gets you here.

147
00:09:31,230 --> 00:09:33,010
Excuse me for this get high.

148
00:09:33,030 --> 00:09:33,490
OK.

149
00:09:33,720 --> 00:09:39,900
And here we have this iTunes stuff that get kind the collection name that said takes iTunes stuff that

150
00:09:39,900 --> 00:09:45,020
get collection name takes the tracks name it takes iTunes the stuff that get thrax name.

151
00:09:45,150 --> 00:09:47,650
And it's very simple and straightforward.

152
00:09:47,700 --> 00:09:53,150
I m g r That said the image bitmap bitmap so that this bitmap is actually declared in our main activity

153
00:09:53,160 --> 00:09:57,490
class and in our background if we are actually instantiating this object.

154
00:09:57,750 --> 00:10:02,410
And now in our unput unposed they say you add method which is going to be executed on the UI thread.

155
00:10:02,430 --> 00:10:05,530
After the Smurfette background is going up.

156
00:10:05,550 --> 00:10:07,610
We are actually assigning the speed map to our.

157
00:10:07,620 --> 00:10:09,100
I am art image view.

158
00:10:09,450 --> 00:10:11,330
And here we have this statement.

159
00:10:11,490 --> 00:10:17,180
So when the job is done and we have those information on our user interface here we want to actually

160
00:10:17,190 --> 00:10:18,840
dismiss the progress they like.

161
00:10:18,840 --> 00:10:23,580
So if progress they like that is showing progress they like that dismiss.

162
00:10:23,580 --> 00:10:29,860
So now let's actually as you can see here inside our main activity class let's actually make this bartend

163
00:10:29,890 --> 00:10:33,320
this BT and get the top button or listen into the police of the user.

164
00:10:33,330 --> 00:10:40,830
So BT and get data that said unclick listener and here we need to pass the context.

165
00:10:40,830 --> 00:10:42,290
Main activity that this.

166
00:10:42,390 --> 00:10:47,210
And then we need to actually implement the unclick less than an employee interface in our class.

167
00:10:47,220 --> 00:10:56,370
Main activity then our compact activity implements a view that unclick listener interface.

168
00:10:56,430 --> 00:11:00,330
So we need to actually override the Smurfette in our class.

169
00:11:00,390 --> 00:11:07,080
So now in our class after the ending curly brace of this uncreate method now I when to override that

170
00:11:07,080 --> 00:11:07,470
method.

171
00:11:07,500 --> 00:11:11,550
So here I can just type in unclick as you can see here.

172
00:11:11,820 --> 00:11:14,560
And now I overjoyed that this Mefford uncle is here.

173
00:11:14,610 --> 00:11:15,050
OK.

174
00:11:15,060 --> 00:11:19,680
So when the user clicks on the spot in here this unclick if it is going to be executed.

175
00:11:19,890 --> 00:11:25,650
So now I need to actually I just need to create an object of type Dasent iTunes stuff task as you can

176
00:11:25,650 --> 00:11:28,820
see here on iTunes stuff task.

177
00:11:28,870 --> 00:11:29,400
OK.

178
00:11:29,640 --> 00:11:36,060
And the name of this object is going to be based on iTunes stuff task assignment operator new Jason

179
00:11:36,510 --> 00:11:37,930
right stuff test.

180
00:11:38,010 --> 00:11:43,200
And here we need to pass the context and activity that this main activity that this is going to be the

181
00:11:43,200 --> 00:11:46,690
context and I need to put a semicolon at the end of my statement.

182
00:11:46,710 --> 00:11:51,960
So as you can see here in say the constructor of the states on items stuff passed I actually created

183
00:11:51,960 --> 00:11:58,020
a constructor that can accept a context or an object of type context and that's why we need to pass

184
00:11:58,020 --> 00:12:04,480
this main activity that this context here as an argument of this kind of structure here for this class

185
00:12:04,500 --> 00:12:06,130
it's on iTunes stuff task.

186
00:12:06,510 --> 00:12:13,620
And here I just need to type in Dasen items stuff task that executes and then I need to put a semicolon

187
00:12:13,650 --> 00:12:14,980
at the end of my statement.

188
00:12:15,210 --> 00:12:19,400
So now let's run our project and see what happens.

189
00:12:19,440 --> 00:12:23,770
So now as you can see our application is running on this emulator.

190
00:12:23,820 --> 00:12:27,860
So now let's actually click on this button here to get the data and data from the Internet.

191
00:12:28,150 --> 00:12:30,690
And now as you can see it we cannot actually see those data.

192
00:12:30,690 --> 00:12:32,560
We cannot get the data from the Internet.

193
00:12:32,640 --> 00:12:39,570
So there is an error in our project and the and the error is inside of this manifest file and it manifests

194
00:12:39,570 --> 00:12:40,530
that example.

195
00:12:40,680 --> 00:12:44,430
And inside this manifest tag here we need to actually put our permission.

196
00:12:44,580 --> 00:12:51,020
So just open a tag and just type in users permission and we need to actually get the internet permission.

197
00:12:51,240 --> 00:12:53,210
And then I need to close this tag here.

198
00:12:53,250 --> 00:12:56,620
This line of code here is very important to me to get the internet permission.

199
00:12:56,910 --> 00:12:59,400
So let's actually run our project again.

200
00:12:59,850 --> 00:13:03,320
So now as you can see our application is running on this emulator.

201
00:13:03,360 --> 00:13:07,800
So let's actually click on this button here and now we have this progress.

202
00:13:07,910 --> 00:13:10,110
Like downloading info from the Internet.

203
00:13:10,500 --> 00:13:13,920
And as you can see here we can see these data type tracks.

204
00:13:14,010 --> 00:13:21,330
As you can see here artist named Michael Jackson collection and the essential Michael Jackson and name

205
00:13:21,330 --> 00:13:23,430
is disvalue P. whitey.

206
00:13:23,490 --> 00:13:26,130
Pretty clean and kind son.

207
00:13:26,250 --> 00:13:29,120
And this is the image that we actually downloaded from the Internet.

208
00:13:29,310 --> 00:13:30,130
OK.

209
00:13:30,240 --> 00:13:34,970
And now we can see that our button is actually disappeared.

210
00:13:35,010 --> 00:13:37,850
So we need to go back to an activity Underland minute example here.

211
00:13:37,860 --> 00:13:39,060
So here I have this error.

212
00:13:39,060 --> 00:13:44,700
I just need to click on this clear cache and it's actually double click on this activity Underland minute

213
00:13:44,720 --> 00:13:49,110
Exuma tap here in order to make this a user interface area wider.

214
00:13:49,560 --> 00:13:56,530
So now I can actually for example select this image view here and assign the value of one hundred.

215
00:13:56,530 --> 00:14:03,280
Here I can just assign the value of 100 for the lay out feet and 100 for the layout height.

216
00:14:03,420 --> 00:14:04,610
OK.

217
00:14:05,550 --> 00:14:07,810
So let's actually Iran our project again.

218
00:14:07,920 --> 00:14:12,590
So again it's actually kind of spot in here and this is our progress dialog.

219
00:14:12,600 --> 00:14:16,500
And now as you can see the information is actually downloaded from the Internet.

220
00:14:16,680 --> 00:14:17,610
OK.

221
00:14:18,180 --> 00:14:24,740
So hopefully that makes sense and I'll make sure that you actually practice on the skills that are hard

222
00:14:24,750 --> 00:14:26,820
for you in this application.

223
00:14:26,820 --> 00:14:32,040
This is really important that you become a master in actually getting the adjacent data from the Internet.

224
00:14:32,040 --> 00:14:38,700
This is a very important concept in Android and if you have any questions about Jason about these concepts

225
00:14:38,700 --> 00:14:43,470
that I taught you in this lesson please post the discussion in the course and let me know about those

226
00:14:43,470 --> 00:14:48,220
problems and I'll do my best to answer all of your questions.

227
00:14:48,250 --> 00:14:50,250
So thank you very much for watching.

228
00:14:50,340 --> 00:14:52,590
And I'll see you in the next tutorial.

