1
00:00:00,720 --> 00:00:05,430
We'll come back, the next thing that I would like to implement is the my profile functionality and

2
00:00:05,430 --> 00:00:07,140
we will do that in multiple steps.

3
00:00:07,140 --> 00:00:13,650
So first of all, we want to get the user data in general to populate this top left corner here to display

4
00:00:13,650 --> 00:00:18,720
the user name and then also prepare at least a code that will display the image of the user.

5
00:00:18,900 --> 00:00:25,230
And when it comes to downloading images from the cloud in our case, where you're downloading it from

6
00:00:25,800 --> 00:00:28,800
storage here, not yet, but we will do so in the future.

7
00:00:29,040 --> 00:00:32,689
And when we do that, it makes sense to work with a third party library.

8
00:00:32,700 --> 00:00:34,470
In this case, it's to glide one.

9
00:00:34,710 --> 00:00:40,140
So Glide is a fast and efficient open source, media management and image loading framework for Android

10
00:00:40,140 --> 00:00:43,410
at frappes, media, decoding, memory and this caching.

11
00:00:43,410 --> 00:00:48,390
And this will make our life a lot easier when it comes to downloading images.

12
00:00:48,390 --> 00:00:48,590
Right.

13
00:00:48,600 --> 00:00:53,520
So that's the idea here, Klyde, with my fragment and load URL.

14
00:00:54,090 --> 00:01:00,000
So whether you want to crop it center or whether you want to adjust it, however, then the placeholder

15
00:01:00,000 --> 00:01:04,769
that you want to use and then finally in which UI element you want to put it.

16
00:01:05,010 --> 00:01:05,400
All right.

17
00:01:05,410 --> 00:01:08,070
So that's what GLI does and that's what we're going to use now.

18
00:01:09,160 --> 00:01:12,790
Therefore, let's go back to our code and start with.

19
00:01:14,240 --> 00:01:20,480
The sign in user from our Firestar class, so we need to adjust it a little bit so that we can use it

20
00:01:20,480 --> 00:01:22,110
in multiple activities.

21
00:01:22,670 --> 00:01:27,560
So let's go to our Firebase or Firestar class here.

22
00:01:28,590 --> 00:01:34,810
So I have this function, which is called sign and user, and I need to make minor changes to it.

23
00:01:35,130 --> 00:01:42,780
So, for example, in The Unsuccess Listener, currently I'm running Sinon success, and that is the

24
00:01:42,780 --> 00:01:44,580
function in our sign in activity.

25
00:01:45,060 --> 00:01:53,130
OK, so this basically this part here only works if the activity that calls this is a sign that activity.

26
00:01:54,090 --> 00:01:57,070
But or at least if the activity that is passed in here.

27
00:01:57,090 --> 00:02:00,630
So we're passing in activity, which is the sign in activity.

28
00:02:01,170 --> 00:02:08,220
And I want to replace this with a basic activity so that it cannot only be a sign activity, but it

29
00:02:08,220 --> 00:02:12,200
could also, for example, be a main activity or something like that.

30
00:02:12,660 --> 00:02:19,620
So let's import activity here and then here we need to check if the activity is of a certain type.

31
00:02:19,890 --> 00:02:22,020
So when activity.

32
00:02:23,560 --> 00:02:28,300
And now it becomes interesting, so is a sign in activity then?

33
00:02:29,490 --> 00:02:38,070
Sign in activity this one, then run some code and the code that it should run, well, it's the same

34
00:02:38,070 --> 00:02:39,120
that we had before.

35
00:02:39,990 --> 00:02:45,450
OK, so now it's going to work because now it is a sign that activity is activity, but otherwise,

36
00:02:45,480 --> 00:02:47,870
if, for example, it is a main activity.

37
00:02:47,880 --> 00:02:53,380
So if his main activity then runs some other code.

38
00:02:53,640 --> 00:03:02,850
So in this case, run a method called activity dot update navigation user details.

39
00:03:05,210 --> 00:03:10,900
This method will also need to know who is the logged in user, so we pass in the logged in user.

40
00:03:10,930 --> 00:03:14,260
Now, of course, we need to create this function in our main activity.

41
00:03:14,450 --> 00:03:15,880
So let's go ahead and create it.

42
00:03:16,400 --> 00:03:24,730
So fun update navigation user details and it needs some information here, right.

43
00:03:26,210 --> 00:03:29,600
To be more precise, it needs a user object.

44
00:03:29,630 --> 00:03:31,520
So here, user of type user.

45
00:03:32,180 --> 00:03:35,540
So let's see here logged in user, by the way.

46
00:03:35,960 --> 00:03:37,520
It's of type user.

47
00:03:37,550 --> 00:03:41,390
We transfer the document, which is if you recall.

48
00:03:42,990 --> 00:03:49,320
This document in our database, so here users, is the collection, right, and then we have the document,

49
00:03:49,320 --> 00:03:54,510
which is the user, so we download this user and we make an object from it, which is of type user,

50
00:03:54,510 --> 00:03:56,010
which is the class that we prepared.

51
00:03:56,730 --> 00:04:02,610
So which is this model that we developed quite some videos ago.

52
00:04:02,880 --> 00:04:03,360
All right.

53
00:04:03,360 --> 00:04:07,830
So here we have the ID name, email image and so forth.

54
00:04:09,370 --> 00:04:15,700
OK, so now we get a user, so let's import user, and this is not the firebase user, but the project

55
00:04:15,700 --> 00:04:18,040
manager or project manager user.

56
00:04:19,269 --> 00:04:24,820
And in here, I want to load the image from the user, right, so user has the information about the

57
00:04:24,820 --> 00:04:25,180
image.

58
00:04:25,300 --> 00:04:26,140
So it's this one.

59
00:04:26,800 --> 00:04:34,430
And I want to set it to be the image which is inside of our nav hatemi.

60
00:04:34,870 --> 00:04:36,490
So here we have this.

61
00:04:37,370 --> 00:04:41,090
Image view, which currently doesn't have a name, so let's give it the name.

62
00:04:42,220 --> 00:04:48,940
I'd I'd nev user image, something like that.

63
00:04:49,390 --> 00:04:51,460
All right, so it's inside of our.

64
00:04:52,430 --> 00:04:59,180
NAV Hederman, which is basically this image here, so I want to be able to access it and adjust it,

65
00:04:59,570 --> 00:05:00,440
so that's what I'm doing.

66
00:05:00,450 --> 00:05:06,950
I'm saying, okay, give me the ID now and now in our main activity and update navigation user details.

67
00:05:06,950 --> 00:05:13,190
I want to update the image and also maybe the text here at the bottom so that it says the user name,

68
00:05:13,760 --> 00:05:14,080
OK?

69
00:05:14,110 --> 00:05:17,140
And if you want to do that, what you need to do is, of course, to use glide.

70
00:05:17,630 --> 00:05:20,120
So we saw Glide just a second ago.

71
00:05:21,250 --> 00:05:22,630
This is the code that you will need.

72
00:05:22,960 --> 00:05:26,680
So let's just use that, so let's put it in here.

73
00:05:27,670 --> 00:05:33,910
We need you, of course, at the dependancy, so let's go over to our.

74
00:05:35,220 --> 00:05:35,670
Gradle.

75
00:05:36,620 --> 00:05:43,550
Here, resources, hey, this one, well, actually, it's the Cradle Scripts here and Bill Cradle and

76
00:05:43,550 --> 00:05:44,860
at another implementation.

77
00:05:45,650 --> 00:05:48,310
So the one that they say here.

78
00:05:48,320 --> 00:05:49,790
So at this implementation.

79
00:05:52,500 --> 00:05:55,620
And also this annotation process.

80
00:05:55,710 --> 00:05:57,030
So that's a copy both.

81
00:05:58,960 --> 00:06:06,010
And let's add them in here, so come back, take light and come back and take that compiler.

82
00:06:06,070 --> 00:06:06,460
All right.

83
00:06:06,470 --> 00:06:09,910
So those two that sync it so that we can now use Klyde.

84
00:06:10,150 --> 00:06:11,260
So the class light.

85
00:06:12,290 --> 00:06:14,120
Which will then, of course, make our life easier.

86
00:06:15,820 --> 00:06:17,750
And now let's go back to our main activity.

87
00:06:17,770 --> 00:06:20,900
Let's see if Clyde now responds positively.

88
00:06:20,920 --> 00:06:24,960
So still, it wants us to create the new abstract class.

89
00:06:24,970 --> 00:06:27,040
Now we can import it takes a little while.

90
00:06:28,010 --> 00:06:33,950
So now we need to say which fragment we want to use, well, in our case, we don't want to use a fragment,

91
00:06:33,950 --> 00:06:36,680
but we want to use it in a specific activity.

92
00:06:36,680 --> 00:06:39,890
So we're going to use it in this activity, which is the main activity.

93
00:06:40,370 --> 00:06:48,320
Then we need to load a new URL and it's going to be our user image, which is going to contain later

94
00:06:48,320 --> 00:06:50,470
on a year earlier where the image is stored.

95
00:06:51,440 --> 00:06:53,540
Then we want to send to prop it.

96
00:06:53,540 --> 00:06:54,140
That's fine.

97
00:06:54,410 --> 00:06:56,380
And we assign a placeholder.

98
00:06:56,390 --> 00:07:02,210
So we will need a placeholder image here and then finally in which image you want to put it.

99
00:07:02,390 --> 00:07:03,860
So let's have a look.

100
00:07:04,010 --> 00:07:11,520
What the name was was never user image, so let's just put it in naff user image.

101
00:07:12,530 --> 00:07:14,360
Now let's add a placeholder.

102
00:07:16,730 --> 00:07:22,550
So I'm just going to paste in an image to my resources here and to the drawable folder, which is going

103
00:07:22,550 --> 00:07:25,640
to be is icey user placeholder.

104
00:07:28,000 --> 00:07:29,500
OK, well, it was there already.

105
00:07:29,650 --> 00:07:30,160
That's good.

106
00:07:30,190 --> 00:07:34,120
So we have this ice use a placeholder, you probably also have it if you tracked it in.

107
00:07:34,450 --> 00:07:35,740
So let's just use this one.

108
00:07:35,740 --> 00:07:38,410
I see user placeholder.

109
00:07:41,730 --> 00:07:48,210
All right, so this is going to set the image currently for Placeholder, but later on with the image

110
00:07:48,210 --> 00:07:51,390
that we have in the user object.

111
00:07:52,590 --> 00:07:57,600
So, for example, if I want to use this image here, let me copy the link.

112
00:07:57,600 --> 00:08:01,380
And really, this is just for demonstration purposes.

113
00:08:01,860 --> 00:08:03,290
Don't use it like that.

114
00:08:03,870 --> 00:08:11,670
And then here I'm just going to edit the string with the value of this Homosassa link so that we will

115
00:08:11,670 --> 00:08:12,490
have an image now.

116
00:08:12,510 --> 00:08:15,840
For me, this is going to be Dennis Panchita or Dennis Agema.

117
00:08:15,840 --> 00:08:20,550
Lidcombe will have this image now so we can use it for testing purposes.

118
00:08:22,030 --> 00:08:26,740
So that it hopefully will not use the placeholder, but it will actually load it from the user image.

119
00:08:27,220 --> 00:08:29,510
OK, so that is just the user image.

120
00:08:29,550 --> 00:08:32,500
Now, we also want to set the text and now let's do that.

121
00:08:32,890 --> 00:08:37,419
TV user name text equals user dot name.

122
00:08:41,120 --> 00:08:48,740
And then at that point, we can go to the uncreate function and here we will just call this function

123
00:08:48,740 --> 00:08:52,010
that we just prepared Soulfire store class.

124
00:08:53,510 --> 00:08:59,810
Thought sign and user, and here we posehn this activity.

125
00:09:00,570 --> 00:09:03,390
OK, so now the signing user is this one, right?

126
00:09:03,410 --> 00:09:06,190
The function that we had before, but we just adjust it.

127
00:09:06,200 --> 00:09:08,650
So now it's going to work accordingly.

128
00:09:08,660 --> 00:09:14,930
So if we sign then as well within the sign in activity, then it's just going to use the sign and success

129
00:09:14,930 --> 00:09:15,290
function.

130
00:09:15,290 --> 00:09:20,660
Otherwise it's going to create or use this function that we just created, which just going to set the

131
00:09:20,660 --> 00:09:23,350
image and the user name text.

132
00:09:23,360 --> 00:09:29,340
So this TV user name, by the way, is this user name here, which currently I think is empty.

133
00:09:29,390 --> 00:09:30,260
Yeah, it's empty.

134
00:09:30,270 --> 00:09:31,150
There's nothing in there.

135
00:09:31,340 --> 00:09:32,630
So we want to change that.

136
00:09:35,240 --> 00:09:43,370
And then there's one more thing, and on failure listener, I would like to also make sure that I'm

137
00:09:43,730 --> 00:09:50,210
at one point calling the progress bar Soheir activity.

138
00:09:51,180 --> 00:09:53,580
Thought Hide Progress bar.

139
00:09:56,210 --> 00:10:00,920
Our progress dialogue, it was now the thing is, and this case, I need to have the same structure

140
00:10:00,920 --> 00:10:02,990
as we had here because.

141
00:10:04,080 --> 00:10:11,280
It doesn't know that the activity is of a certain type, so in either case, I just want to run activity,

142
00:10:11,280 --> 00:10:13,710
hide progress, dialogue.

143
00:10:16,650 --> 00:10:20,800
Even though this seems to be duplicate code, it's still necessary, right?

144
00:10:21,390 --> 00:10:25,920
And by the way, this should be inside of the the expression.

145
00:10:27,610 --> 00:10:28,050
Buddy.

146
00:10:29,130 --> 00:10:29,640
OK.

147
00:10:31,900 --> 00:10:36,460
So basically, when the activity is assigned an activity used to hide progress, dialogue, and what

148
00:10:36,460 --> 00:10:42,460
is the main activity used to hide progress dialogue, in both cases, it's just going to call this function,

149
00:10:42,460 --> 00:10:44,500
which is inside of our base activity.

150
00:10:44,920 --> 00:10:49,990
But still, at that point, it doesn't know that what kind of activity it is.

151
00:10:50,290 --> 00:10:54,040
And that's why we need to define it specifically here.

152
00:10:56,800 --> 00:11:02,200
And by the way, if we now tested, what we will see is that we have this beautiful Homer Simpson image

153
00:11:02,200 --> 00:11:06,080
here, it's cropped centrally and we also have the username here.

154
00:11:06,820 --> 00:11:07,330
All right.

155
00:11:07,900 --> 00:11:09,340
So let's test it.

156
00:11:10,080 --> 00:11:15,640
Let's go over here and replace the name from Dennis to Homer.

157
00:11:16,880 --> 00:11:21,230
And I'll update this and go back to our application.

158
00:11:21,410 --> 00:11:22,850
Sign out and sign in again.

159
00:11:23,730 --> 00:11:24,780
So sign in.

160
00:11:26,520 --> 00:11:27,550
He is still the same.

161
00:11:27,570 --> 00:11:28,520
It didn't change, right?

162
00:11:29,490 --> 00:11:32,340
And of it is also the same.

163
00:11:35,240 --> 00:11:41,090
So now we should see that it says Homer and the little image of Homer, even though the image is not

164
00:11:41,090 --> 00:11:47,840
perfectly positioned and everything, but that is something that you can, of course, define when developing

165
00:11:47,840 --> 00:11:48,610
it in here.

166
00:11:48,620 --> 00:11:50,090
So in your.

167
00:11:51,990 --> 00:11:58,570
Main activity and the update navigation function, so here you have multiple different options.

168
00:11:58,740 --> 00:12:02,670
Now, of course, if you want to play around with the values you can see here, download and set up

169
00:12:02,670 --> 00:12:03,480
the next page.

170
00:12:04,140 --> 00:12:06,790
There, you find a lot more information.

171
00:12:06,810 --> 00:12:09,380
So this is a proper documentation that you have here.

172
00:12:09,390 --> 00:12:15,780
For example, transformation's, you can see built in types are sent, cropped, fit, center, circle,

173
00:12:15,790 --> 00:12:16,110
KRUP.

174
00:12:16,320 --> 00:12:18,810
So these are the different options that they offer here.

175
00:12:19,050 --> 00:12:25,590
Of course, you can define your own if you want, but these are the ones that are available automatically.

176
00:12:27,440 --> 00:12:29,030
All right, so that is it for now.

177
00:12:29,030 --> 00:12:34,640
In the next video, we are going to prepare the profile screen, so just the activity with the UI and

178
00:12:34,640 --> 00:12:40,250
then in the following video, we are going to add the functionality to also load the data into that

179
00:12:40,280 --> 00:12:40,790
UI.

180
00:12:41,270 --> 00:12:41,630
All right.

181
00:12:41,630 --> 00:12:44,070
But at this point, you already know how to do that, right?

182
00:12:44,090 --> 00:12:46,090
So you've seen it multiple times already.

183
00:12:46,100 --> 00:12:52,430
So if you feel comfortable with this and feel self-confident to start this, I would highly recommend

184
00:12:52,430 --> 00:12:52,940
to do this.

185
00:12:52,940 --> 00:12:58,100
Even if you don't feel self-confident and don't feel like doing it, I still recommend to do it because

186
00:12:58,100 --> 00:13:05,280
I think this is the kind of stuff that will help you to really learn it completely.

187
00:13:05,300 --> 00:13:07,460
So really learn how to do it in the future.

188
00:13:07,700 --> 00:13:09,350
Just watching me is not going to be enough.

189
00:13:09,380 --> 00:13:09,780
All right.

190
00:13:09,800 --> 00:13:12,740
So please try it yourself and good luck with it.

191
00:13:13,220 --> 00:13:16,370
And thanks a lot again for still being part of the course.

192
00:13:16,910 --> 00:13:18,110
See you in the next video.

