We'll come back, the next thing that I would like to implement is the my profile functionality and
we will do that in multiple steps.
So first of all, we want to get the user data in general to populate this top left corner here to display
the user name and then also prepare at least a code that will display the image of the user.
And when it comes to downloading images from the cloud in our case, where you're downloading it from
storage here, not yet, but we will do so in the future.
And when we do that, it makes sense to work with a third party library.
In this case, it's to glide one.
So Glide is a fast and efficient open source, media management and image loading framework for Android
at frappes, media, decoding, memory and this caching.
And this will make our life a lot easier when it comes to downloading images.
Right.
So that's the idea here, Klyde, with my fragment and load URL.
So whether you want to crop it center or whether you want to adjust it, however, then the placeholder
that you want to use and then finally in which UI element you want to put it.
All right.
So that's what GLI does and that's what we're going to use now.
Therefore, let's go back to our code and start with.
The sign in user from our Firestar class, so we need to adjust it a little bit so that we can use it
in multiple activities.
So let's go to our Firebase or Firestar class here.
So I have this function, which is called sign and user, and I need to make minor changes to it.
So, for example, in The Unsuccess Listener, currently I'm running Sinon success, and that is the
function in our sign in activity.
OK, so this basically this part here only works if the activity that calls this is a sign that activity.
But or at least if the activity that is passed in here.
So we're passing in activity, which is the sign in activity.
And I want to replace this with a basic activity so that it cannot only be a sign activity, but it
could also, for example, be a main activity or something like that.
So let's import activity here and then here we need to check if the activity is of a certain type.
So when activity.
And now it becomes interesting, so is a sign in activity then?
Sign in activity this one, then run some code and the code that it should run, well, it's the same
that we had before.
OK, so now it's going to work because now it is a sign that activity is activity, but otherwise,
if, for example, it is a main activity.
So if his main activity then runs some other code.
So in this case, run a method called activity dot update navigation user details.
This method will also need to know who is the logged in user, so we pass in the logged in user.
Now, of course, we need to create this function in our main activity.
So let's go ahead and create it.
So fun update navigation user details and it needs some information here, right.
To be more precise, it needs a user object.
So here, user of type user.
So let's see here logged in user, by the way.
It's of type user.
We transfer the document, which is if you recall.
This document in our database, so here users, is the collection, right, and then we have the document,
which is the user, so we download this user and we make an object from it, which is of type user,
which is the class that we prepared.
So which is this model that we developed quite some videos ago.
All right.
So here we have the ID name, email image and so forth.
OK, so now we get a user, so let's import user, and this is not the firebase user, but the project
manager or project manager user.
And in here, I want to load the image from the user, right, so user has the information about the
image.
So it's this one.
And I want to set it to be the image which is inside of our nav hatemi.
So here we have this.
Image view, which currently doesn't have a name, so let's give it the name.
I'd I'd nev user image, something like that.
All right, so it's inside of our.
NAV Hederman, which is basically this image here, so I want to be able to access it and adjust it,
so that's what I'm doing.
I'm saying, okay, give me the ID now and now in our main activity and update navigation user details.
I want to update the image and also maybe the text here at the bottom so that it says the user name,
OK?
And if you want to do that, what you need to do is, of course, to use glide.
So we saw Glide just a second ago.
This is the code that you will need.
So let's just use that, so let's put it in here.
We need you, of course, at the dependancy, so let's go over to our.
Gradle.
Here, resources, hey, this one, well, actually, it's the Cradle Scripts here and Bill Cradle and
at another implementation.
So the one that they say here.
So at this implementation.
And also this annotation process.
So that's a copy both.
And let's add them in here, so come back, take light and come back and take that compiler.
All right.
So those two that sync it so that we can now use Klyde.
So the class light.
Which will then, of course, make our life easier.
And now let's go back to our main activity.
Let's see if Clyde now responds positively.
So still, it wants us to create the new abstract class.
Now we can import it takes a little while.
So now we need to say which fragment we want to use, well, in our case, we don't want to use a fragment,
but we want to use it in a specific activity.
So we're going to use it in this activity, which is the main activity.
Then we need to load a new URL and it's going to be our user image, which is going to contain later
on a year earlier where the image is stored.
Then we want to send to prop it.
That's fine.
And we assign a placeholder.
So we will need a placeholder image here and then finally in which image you want to put it.
So let's have a look.
What the name was was never user image, so let's just put it in naff user image.
Now let's add a placeholder.
So I'm just going to paste in an image to my resources here and to the drawable folder, which is going
to be is icey user placeholder.
OK, well, it was there already.
That's good.
So we have this ice use a placeholder, you probably also have it if you tracked it in.
So let's just use this one.
I see user placeholder.
All right, so this is going to set the image currently for Placeholder, but later on with the image
that we have in the user object.
So, for example, if I want to use this image here, let me copy the link.
And really, this is just for demonstration purposes.
Don't use it like that.
And then here I'm just going to edit the string with the value of this Homosassa link so that we will
have an image now.
For me, this is going to be Dennis Panchita or Dennis Agema.
Lidcombe will have this image now so we can use it for testing purposes.
So that it hopefully will not use the placeholder, but it will actually load it from the user image.
OK, so that is just the user image.
Now, we also want to set the text and now let's do that.
TV user name text equals user dot name.
And then at that point, we can go to the uncreate function and here we will just call this function
that we just prepared Soulfire store class.
Thought sign and user, and here we posehn this activity.
OK, so now the signing user is this one, right?
The function that we had before, but we just adjust it.
So now it's going to work accordingly.
So if we sign then as well within the sign in activity, then it's just going to use the sign and success
function.
Otherwise it's going to create or use this function that we just created, which just going to set the
image and the user name text.
So this TV user name, by the way, is this user name here, which currently I think is empty.
Yeah, it's empty.
There's nothing in there.
So we want to change that.
And then there's one more thing, and on failure listener, I would like to also make sure that I'm
at one point calling the progress bar Soheir activity.
Thought Hide Progress bar.
Our progress dialogue, it was now the thing is, and this case, I need to have the same structure
as we had here because.
It doesn't know that the activity is of a certain type, so in either case, I just want to run activity,
hide progress, dialogue.
Even though this seems to be duplicate code, it's still necessary, right?
And by the way, this should be inside of the the expression.
Buddy.
OK.
So basically, when the activity is assigned an activity used to hide progress, dialogue, and what
is the main activity used to hide progress dialogue, in both cases, it's just going to call this function,
which is inside of our base activity.
But still, at that point, it doesn't know that what kind of activity it is.
And that's why we need to define it specifically here.
And by the way, if we now tested, what we will see is that we have this beautiful Homer Simpson image
here, it's cropped centrally and we also have the username here.
All right.
So let's test it.
Let's go over here and replace the name from Dennis to Homer.
And I'll update this and go back to our application.
Sign out and sign in again.
So sign in.
He is still the same.
It didn't change, right?
And of it is also the same.
So now we should see that it says Homer and the little image of Homer, even though the image is not
perfectly positioned and everything, but that is something that you can, of course, define when developing
it in here.
So in your.
Main activity and the update navigation function, so here you have multiple different options.
Now, of course, if you want to play around with the values you can see here, download and set up
the next page.
There, you find a lot more information.
So this is a proper documentation that you have here.
For example, transformation's, you can see built in types are sent, cropped, fit, center, circle,
KRUP.
So these are the different options that they offer here.
Of course, you can define your own if you want, but these are the ones that are available automatically.
All right, so that is it for now.
In the next video, we are going to prepare the profile screen, so just the activity with the UI and
then in the following video, we are going to add the functionality to also load the data into that
UI.
All right.
But at this point, you already know how to do that, right?
So you've seen it multiple times already.
So if you feel comfortable with this and feel self-confident to start this, I would highly recommend
to do this.
Even if you don't feel self-confident and don't feel like doing it, I still recommend to do it because
I think this is the kind of stuff that will help you to really learn it completely.
So really learn how to do it in the future.
Just watching me is not going to be enough.
All right.
So please try it yourself and good luck with it.
And thanks a lot again for still being part of the course.
See you in the next video.