And then we have this do in background.
This is really important.
OK.
Do it do in background so it's going to do the task of downloading data from the internet in the background
it.
OK.
So that's why its name is in background and we have this argument Possum's but I'm sorry as you can
see here at in line at 54 74 as you can see we have actually created an object of type stuff.
So remember that because the output of this class this async class is going to be to use stuff the Smurfette
doing background is going to return an object of type human stuff.
So that's why we actually created an object of type items of stuff inside this method and the name of
this object is iTunes stuff.
Assignment operator new iTunes stuff.
So now I have an object of type items and stuff.
And I actually initialize this object here and in line 75 as you can see I created Avari habit of type
strange an object of types think and the name of this value of the name of this variable is data.
So here I want to actually initialize this data right.
So here I actually created an object of of type items husht TTP client.
So new client here is going to actually create an object of type items typically.
OK.
So here we have an object of type or this class item was likely to be client but get items stuff data.
So remember in inside these items how she typically And here we have this Smurfette get items stuff
up which is actually going on download the data from the Internet is going to connect to the Internet
and then what those data are from the Internet.
So that's the job of the Smif it get iTunes stuff data stream.
But inside this main I keep class I am actually creating an object of type II.
Humes husht stipulate this is actually an object.
OK.
And we are calling the Smurfette which is actually an instance method.
OK this is not and this is actually not static.
So we call this object on our Smurfette we are actually calling this method on an object of type.
ITunes has typically OK.
New items Hashid to be client that get iTunes stuff later.
So its going to get that data and put those data inside this data are valuable here and here we have
this try catch block.
So try to use stuff.
So he had referred to the name of this object.
HUME stuff assignment operator Jason iTunes parser.
So he had referred to the name of this class Jason iTunes part Parsa that I have in my project as you
can see here.
And we have this static method inside our class.
Ok iTunes stuff.
Get the iTunes stuff OK.
So inside this main activity class I referred to the name of this place on iTunes parser class that
get iTunes stuff later.
So we passed this data to that to the Smurfette and then we are actually getting that data and we are
actually putting that we are actually assigning that to the iTunes stuff later.
So remember this method get iTunes stuff here is going to actually turn an object as you can see inside
the states on iTunes sparser.
This method is going to return an object of type iTunes sparser iTunes stuff as you can see here.
So we are here we are actually signing that return value to these items stuff so we can do that because
the Smurfette is going to return an object of type I stuff.
By this argument as you can see here and then we can actually assign that value that returns value to
these items stuff here which is again off of items stuff right.
And some of it is going to actually accept r.
And then its going to actually parse the values the day somebody is from the Internet and then its going
to pretend that iTunes stuff object.
So let's go back to our main activity that of a fight here.
So now we have that data and now we have as you can see here we are actually assigning that data to
these iTunes stuff.
And then we are actually the initialising this I enjoy you Arel that I actually declared in our main
activity class inside our main activity class here.
I actually declared that these items are valuable which is strange.
11:25.
So here in Meffert in doing background I am I am actually instantiating this valuable.
So I am sure you are an assignment operator.
Items stuff.
So here I referred to the name of this object use stuff that get artist view of it.
So here I am actually getting the artist Gidding artist.
You model that you are and that we can actually download from the internet.
Okay.
And here I am actually that you are that is going to actually allow us to download the image from the
Internet right.
And here I am assigning value to these to you all.
So inside is adjacent iTunes of that class as you can see in line 28 I am getting disvalue art artwork
out and 100 here from this artist object.
So inside me an active I am actually signing that you are Ltds I am sure you are OK by calling items
stuff that get artist view it.
OK and that here that we have this I am gdel in line 81 I am instantiating the bitmap object that I
again declared in line 27 inside our main activity class.
OK.
So here I am instantiating the speed map assignment operator.
I actually created an object of type items hash TTP client.
OK.
As you can see here and here as you can see I am actually calling this method on this object.
Get me get bitmapped from u r l i n g u r.
Ok so here we are calling this method that is inside of these items how shitty because we have this
method here.
In order to download the image from the Internet right.
So I just referred to the name of this method he had inside our main activity class and we are calling
that Befort on this object new iTunes Hostettler client and here we are passing this on I am to you
all here.
And now as you can see here Insite is doing background Mefford I am actually using these new items husht
typically in here two times.
I actually I am actually creating this object two times in my method and I think that's not very good.
That's not really good programming practice.
I can actually create an object of type items how shitty the client and assign that object to a valuable
and then I can actually use that valuable.
So here let's actually create an object of type items.
How should it be a client and the name of this object is going to be items how to be client assignment
operator new iTunes.
How typical are you.
OK.
And then I need to put a semicolon at the end of my statement.
So as you can see here I am actually referring to this object.
Look at here I am actually creating an object of type items such a typical.
So I can't delete this piece of code here and there.
I just referred to the name of this object that I created in line 76.
OK.
Items such a typical.
So as you can see here I am actually creating an object of type I human typically.
And I am assigning that value to this object to this object which is of type items I should decline
this valuable.
And now I can actually read through the name of this variable and call this method and again inside
is Triple H as you can see again I am actually creating an order object of type items to shush the typical
diet.
I can actually use this object here is valuable here that I created inline Sixtus 76 so I can just delete
this piece of code here and I can just type in iTunes.
Hashi typically And as you can see here so this is a very good programming practice that I want to show
you.
So we were actually creating two objects of type.
How should he be.
How should he be client and now we have one object and we are using that object here and here in order
to get that data and download the image from the Internet.
So it has to be client that get treatment from you or I am to you are that as you can see here.
OK.
And by passing this I you are and here we are actually downloading that data from the Internet.
And here I am assigning those data to that image to the speed map here.
OK that's the task that is actually being done in the background.
And here we had we have this catch block here.
So in case some errors happen or we can actually we can't actually connect to the Internet.
So it's going to actually put those errors the information about the errors in the log tedious print
stack trace.
And here we are actually returning to the iTunes stuff return iTunes stuff.
So now I am actually returning the iTunes stuff from the Smurfette between background right.
And we have this on post.
So this is going to be executed on them Fred.
So now we can actually get the information that we received as an argument of this on post executive
Meffert and we can put those information on the for.
So Unbossed thinks it cute.
And then here in line one hundred and one you are calling it the supervision of the Smurfit Superlight
on unposed to execute iTunes stuff.
As you can see here and here as you can see I am actually just setting the text of this text the artist
name that said text iTunes stuff that get artist name as you can see here we are actually receiving
iTunes of stuff object as an argument so iTunes stuff that get artist name the type that said text iTunes
stuff that get type the kind that said text iTunes stuff that gets you here.
Excuse me for this get high.
OK.
And here we have this iTunes stuff that get kind the collection name that said takes iTunes stuff that
get collection name takes the tracks name it takes iTunes the stuff that get thrax name.
And it's very simple and straightforward.
I m g r That said the image bitmap bitmap so that this bitmap is actually declared in our main activity
class and in our background if we are actually instantiating this object.
And now in our unput unposed they say you add method which is going to be executed on the UI thread.
After the Smurfette background is going up.
We are actually assigning the speed map to our.
I am art image view.
And here we have this statement.
So when the job is done and we have those information on our user interface here we want to actually
dismiss the progress they like.
So if progress they like that is showing progress they like that dismiss.
So now let's actually as you can see here inside our main activity class let's actually make this bartend
this BT and get the top button or listen into the police of the user.
So BT and get data that said unclick listener and here we need to pass the context.
Main activity that this.
And then we need to actually implement the unclick less than an employee interface in our class.
Main activity then our compact activity implements a view that unclick listener interface.
So we need to actually override the Smurfette in our class.
So now in our class after the ending curly brace of this uncreate method now I when to override that
method.
So here I can just type in unclick as you can see here.
And now I overjoyed that this Mefford uncle is here.
OK.
So when the user clicks on the spot in here this unclick if it is going to be executed.
So now I need to actually I just need to create an object of type Dasent iTunes stuff task as you can
see here on iTunes stuff task.
OK.
And the name of this object is going to be based on iTunes stuff task assignment operator new Jason
right stuff test.
And here we need to pass the context and activity that this main activity that this is going to be the
context and I need to put a semicolon at the end of my statement.
So as you can see here in say the constructor of the states on items stuff passed I actually created
a constructor that can accept a context or an object of type context and that's why we need to pass
this main activity that this context here as an argument of this kind of structure here for this class
it's on iTunes stuff task.
And here I just need to type in Dasen items stuff task that executes and then I need to put a semicolon
at the end of my statement.
So now let's run our project and see what happens.
So now as you can see our application is running on this emulator.
So now let's actually click on this button here to get the data and data from the Internet.
And now as you can see it we cannot actually see those data.
We cannot get the data from the Internet.
So there is an error in our project and the and the error is inside of this manifest file and it manifests
that example.
And inside this manifest tag here we need to actually put our permission.
So just open a tag and just type in users permission and we need to actually get the internet permission.
And then I need to close this tag here.
This line of code here is very important to me to get the internet permission.
So let's actually run our project again.
So now as you can see our application is running on this emulator.
So let's actually click on this button here and now we have this progress.
Like downloading info from the Internet.
And as you can see here we can see these data type tracks.
As you can see here artist named Michael Jackson collection and the essential Michael Jackson and name
is disvalue P. whitey.
Pretty clean and kind son.
And this is the image that we actually downloaded from the Internet.
OK.
And now we can see that our button is actually disappeared.
So we need to go back to an activity Underland minute example here.
So here I have this error.
I just need to click on this clear cache and it's actually double click on this activity Underland minute
Exuma tap here in order to make this a user interface area wider.
So now I can actually for example select this image view here and assign the value of one hundred.
Here I can just assign the value of 100 for the lay out feet and 100 for the layout height.
OK.
So let's actually Iran our project again.
So again it's actually kind of spot in here and this is our progress dialog.
And now as you can see the information is actually downloaded from the Internet.
OK.
So hopefully that makes sense and I'll make sure that you actually practice on the skills that are hard
for you in this application.
This is really important that you become a master in actually getting the adjacent data from the Internet.
This is a very important concept in Android and if you have any questions about Jason about these concepts
that I taught you in this lesson please post the discussion in the course and let me know about those
problems and I'll do my best to answer all of your questions.
So thank you very much for watching.
And I'll see you in the next tutorial.