Hired Avon in this story are going to go ahead and we're going to download the image that we uploaded
to the firebase in the previous tutorial so you can see that here we have this image just for there.
And inside these images will there we have this image if I click on it you can see this image here.
So let's wait a little bit here so I can see this image.
So now we are going to download this image into our Android application and you're going to put this
image into an image view.
So let's go back to android studio.
So here it is the android studio.
And here let's go to the activity underline made that is now and here inside this appellate section
you can see these images here right.
Just click on it and just select this image and put it into our constraints.
Lay out here.
So now let's select actually a default image here sort of like this one I.C. Lanter I lantern around
and then click on OK.
So let's add some constraints to this image so let's actually select this image and put it here below
the spot in.
And here you can see that these two constraints are automatically created here to that left at the edge
of the screen and to the right edge of the screen.
Right.
So these constraints are created because this option is actually on this we can see that we have some
options here.
Right the first one here allows you to actually see the constraints.
The second option here actually allows you to turn on the auto connect feature of constraints.
So this means that whenever you write a user interface component into it lay out some constraints based
on the actually place that you put that user interface component as are going to be created.
But you can see that these two constraints here are created here.
So now let's create a constraint to the bottom edge of the Spartan.
So just we can see this little circle that is pulsating here on the top edge of this image view.
So create a constraint here to the bottom edge of the spot in here and just it connected to the little
circle that is pulsating on the bottom edge of this button.
So there is a constraint here to the bottom of this button.
Let's change the top margin here to number 20 and then press and until you keyboard select this image
and let's for example I want to actually increase the width and the height of this image so we can actually
change these.
Actually that is of concern here.
So you can see inside this property section if you consider it currently it is wrapped content.
If I click on it now it is what it is actually let me hover over it in order to show you that it is
actually fixed and now it is actually it is not fixed and it is match constraints.
So I wanted this image viewed to take the entire width of eyes of the parent which is going to be the
constraints there.
So you can see that I selected these match constraints here for which constraint.
So now let's I want to increase the height of this image so selected.
And now for the height we can actually change it here if you can for the lay of height let's add the
value 100 and then press and it'll change.
So 100 is good.
Right.
So let's give an ID to this image of you.
So for the artist they can.
IMT downloaded.
I emptied them loaded and then present intention your keyboard.
So let's go to our main activity class let's declared it image here.
Inside me an activity class private's image view and the name of this image is actually AMG download
right.
I am g download.
I notice that your image name here to your rowdier but it means you must not be of type must not be
the same as the ID that you actually specified inside the exemplified.
But here I just decided to use the design name as the name of this.
So you can see this name is the same as the name of the ID that V is specified for the image view inside
or Actimel fight.
So let's go into our uncreate Smurfette here and now let's up is below this line of code that actually
initialises this button.
Let's initialize our image viewer so I m g down low that assignment operator.
And now let's cast this object to an image object find view by id r that Id dot or M G downloaded and
then put a semicolon at the end of your statement right.
So here inside this class let's create two body but this let's actually declare ready to rock the bells
here.
So again just say it in private and then it and the data type of the first value but that we are going
to create here is going to be off the Procrustes dialogue and the name of this variable is going to
be download progress dialog.
Right and then put a semicolon here.
The second variable is going to be of type you are or you are.
And the name of this variable is going to be download.
You are right a semi-colon.
So now that we actually declare these variables it's time to initialize these variables.
So let's go into this uncreate Smurfette here.
So after these two lines of code it actually initializers these user interface components.
Let's initialize our download progress dialog assignment operator and he has just left.
He had new progress dialog like.
So now we just need to pass the context which is going to be main activity that this slight semi-colon.
That's it.
So let's go into our unactivated result to me an activity result if it hit at the bottom.
So here it is our unactivated result method right.
So inside this case statement here.
Case number 1.
If request code is equal to a result.
OK here.
Now I'm going to actually say that a Procrustes dialog with progress they like actually thought sets
message and we can't say downloading image downloading.
Image from firebase from Firebrace dot dot dot.
And now we can actually say download progress.
I like that show semi-colon.
So now we want you to go inside these unsuccess listener here inside is unsuccess the and and Mefford
and after uploading the image after uploading the image to the firebase here.
Now we are going to download the image to our Android application.
So here first we need to get the download you are right from the task snapshot.
So let's see if referred to our downloads.
You are valuable that we created above inside our main activity class assignment operator.
So now we are going to refer to this task snapshot that get download you are the semi-colon.
So I refer to this argument task snapshot and I call it the Smurfit on this argument.
So notice that there is this red line here and there is a bug here.
I think it is this bug is related to Android studio.
Don't forget it is not an error.
OK.
It is not an error.
It is just a bug and it's not going to actually cause problems.
I don't know.
It's not going to cause for example a runtime error or maybe a compile time error.
And after this line of code here I'm going to actually say so remember that we added the Picasso library
to our Android project.
Right.
So we can actually refer to this Picasso class Picazo that we get.
So we need to pass the context here.
Right.
The context is going to be main activity that this dot load.
So now we need to actually pass the file here to this method and see that we have different versions
of this method.
Let me show you this method again.
Load.
If you have different versions of this method that actually access different arguments the first one
accepts or you are right.
The second argument accepts a path the first argument exits a fight and the final argument accepts actually
a resource ID because of that integer.
So we have the you are right we have to download you are here so we can pass it here.
But actually we can't pass down to you are here and now we can actually say that feat.
So it's going to fit the image into our image view but Center Kropp.
OK so it's going to actually put our image into our image view you like this image that we have here.
Right.
You can see the center image view here.
So let's go back to Andrew so that let's go back to our main activity class actually and then we translate
that into.
So now we need to pass the image view.
So we have this I m g download that's it.
So now after actually downloading the image and put it and putting it into our image view we can actually
say download progress they dialog with progress.
They like that this is.
So now let's run the application here let's click on the wrong button here at the bar at the top menu
here.
So let's read a little bit here let's select one of these devices and then click on OK.
So here you can see that our application is running on this emulator.
Let's click on the upload the image to firebase here.
So for example choose this one.
Right now it says Downloading image from firebase uploading was successful.
And now we have this image here into our image view.
So you can see that the entire image is not set into our image view.
That's because of the constraints lay out.
Let's go to our activity and activity on that minute exam and here we can actually select this image.
So for the layout height let's pass the value 200.
Let's run the application again.
Let me show you the emulator.
See that the app is actually running and the simulator lets you can upload the image to firebase this
choose this fun and now it is downloading image from Firebrace.
And now it's going to actually say uploading was successful and now you can see this image here.
That's it.
So if you have any questions about the concepts that I taught you in this lesson please post the discussion
in the course and then I'll do my best to answer all of your questions in the next two years.
I'm going to actually show you how we can upload the voice to firebase.
Right.
So that's it.
And I'll see you in the next tutorial.