1
00:00:00,500 --> 00:00:06,470
We'll come back and this video, we are going to load the profile data off the user, so here we want

2
00:00:06,470 --> 00:00:11,220
to display the data and yeah, let's just go ahead and built that.

3
00:00:11,720 --> 00:00:21,470
So in order to do that in the my profile activity, I will need to call a function which is our fire

4
00:00:21,470 --> 00:00:22,480
restore function.

5
00:00:22,490 --> 00:00:23,930
So I'm just going to do it right here.

6
00:00:24,380 --> 00:00:32,450
Fire store, class, dot sign in user and pass this activity.

7
00:00:32,930 --> 00:00:40,880
So at this point, I think passing in the activity, my profile activity is not going to work.

8
00:00:40,880 --> 00:00:41,150
Right.

9
00:00:41,160 --> 00:00:43,310
So it doesn't understand what's going on.

10
00:00:43,850 --> 00:00:48,680
But I'm also not very happy with the name of this function anymore.

11
00:00:48,710 --> 00:00:53,300
So if we look at a function in our first class.

12
00:00:54,170 --> 00:00:55,350
So an end user.

13
00:00:56,390 --> 00:00:59,020
OK, I called it, I wrote it correctly.

14
00:00:59,450 --> 00:01:06,020
But the thing is, we are not really signing in the user anymore when we update the navigation user

15
00:01:06,020 --> 00:01:06,640
details.

16
00:01:06,890 --> 00:01:13,280
So how I want to rename this function is I'm going to rename it to.

17
00:01:15,580 --> 00:01:19,420
Load user data, so load user data.

18
00:01:19,810 --> 00:01:25,040
I think this is going to be more descriptive because it's really just loading user data and one case

19
00:01:25,040 --> 00:01:27,970
that's signing in the user and logging in the user done.

20
00:01:27,970 --> 00:01:31,330
And the other one, it's updating the navigation user details.

21
00:01:31,330 --> 00:01:37,620
And then the third one, which we had now is our my profile activity.

22
00:01:38,410 --> 00:01:45,190
So in that case, what it should do is it should call a function from the profile activity.

23
00:01:47,090 --> 00:01:48,510
And give it to user data.

24
00:01:48,530 --> 00:01:48,830
All right.

25
00:01:50,020 --> 00:01:52,410
So let's go out and create a new function here.

26
00:01:54,020 --> 00:01:59,240
I'm going to create a new function called Set User Data in UI.

27
00:02:00,250 --> 00:02:06,850
And Anita, a user here, and then I can go ahead and display the.

28
00:02:08,580 --> 00:02:13,440
Image, first of all, so here I'm using the model's user, by the way.

29
00:02:14,010 --> 00:02:18,000
So we are going to use the same function that we used before.

30
00:02:18,000 --> 00:02:22,230
We're going to use this glide function now, this time with the profile activity.

31
00:02:22,500 --> 00:02:25,110
We load the user image, we crop it.

32
00:02:25,260 --> 00:02:30,350
Then alternatively, we used to use a placeholder and where do we want to use it?

33
00:02:30,360 --> 00:02:33,790
Well, in our IVI user image.

34
00:02:34,140 --> 00:02:36,690
Now, to make sure that this is the correct one.

35
00:02:37,050 --> 00:02:46,530
Let's go to our profile XML file this one and see if we actually called the image IVI user image, just

36
00:02:46,530 --> 00:02:47,200
to be sure.

37
00:02:48,180 --> 00:02:52,140
So it's at the very top, I think inside of the card view.

38
00:02:52,140 --> 00:02:54,810
So circle view, it's just one.

39
00:02:55,110 --> 00:02:58,490
I have a user image inside of our activity in my profile.

40
00:02:58,500 --> 00:02:58,750
Right.

41
00:02:59,070 --> 00:03:02,430
So that's the one that I want to assign here.

42
00:03:04,070 --> 00:03:04,910
This image to.

43
00:03:06,000 --> 00:03:12,150
OK, so this is just one step, and of course, we also want to get the name of the user or set the

44
00:03:12,150 --> 00:03:17,060
name of the user with the text of user name.

45
00:03:17,820 --> 00:03:23,900
Then the email said text with user dot email.

46
00:03:24,660 --> 00:03:28,350
And then if there is a user mobile number.

47
00:03:28,950 --> 00:03:42,600
So user dot mobile is not equal now or zero has a long value, then also set the number so he t mobile

48
00:03:43,080 --> 00:03:50,640
set text user dot mobile to string because otherwise it would look weird if just not a zero would be

49
00:03:50,640 --> 00:03:51,180
entered there.

50
00:03:51,180 --> 00:03:51,480
Right.

51
00:03:52,020 --> 00:03:56,410
So if we look at it, if I zero would be the mobile number, I think this is not good.

52
00:03:57,030 --> 00:03:59,270
So that's why we do this check here.

53
00:03:59,520 --> 00:04:08,340
If zero is stored in the user object, which basically is what we get when we download the document.

54
00:04:09,900 --> 00:04:15,240
So when we download this document, we get this mobile number, which is zero, and if it's zero, we

55
00:04:15,240 --> 00:04:16,050
don't want to use it.

56
00:04:17,990 --> 00:04:19,010
And that's what we do here.

57
00:04:19,040 --> 00:04:22,750
So if it's not zero, then we want to use to number that is stored there.

58
00:04:24,550 --> 00:04:31,570
All right, and that is the function that I want to use here, by the way, it's not an end user anymore.

59
00:04:31,620 --> 00:04:32,890
Now it's called.

60
00:04:33,910 --> 00:04:44,650
So store class that could not not got current user already, part load user data and I passan this activity.

61
00:04:45,920 --> 00:04:56,180
OK, so now what we need to do is we need to run the code here, so activity that said user data in

62
00:04:56,180 --> 00:04:57,980
UI with logged in user.

63
00:04:58,670 --> 00:05:08,720
So you see we we here say, OK, activity, please call this function inside of our my profile activity.

64
00:05:08,960 --> 00:05:15,170
But before that we say in my profile activity, please call this function, which then in turn calls

65
00:05:15,170 --> 00:05:22,130
this function here, but then it also gives us the user name or not just the user name, but the whole

66
00:05:22,130 --> 00:05:22,820
user object.

67
00:05:22,820 --> 00:05:23,030
Right.

68
00:05:23,270 --> 00:05:24,350
So that is the idea.

69
00:05:24,350 --> 00:05:30,500
It's really we go from the my profile activity over to first class.

70
00:05:30,680 --> 00:05:32,000
We call this function.

71
00:05:32,300 --> 00:05:40,040
This function goes back to the activity, which is are my profile activity, and then calls the function

72
00:05:40,040 --> 00:05:40,910
inside of this one.

73
00:05:41,060 --> 00:05:42,410
But this time we get the user.

74
00:05:42,410 --> 00:05:43,880
That's the huge difference.

75
00:05:43,880 --> 00:05:44,100
Right.

76
00:05:44,120 --> 00:05:45,950
So we just wanted to have the user.

77
00:05:46,190 --> 00:05:53,360
And the thing is, we already have this class which gives us or this method even which gives us the

78
00:05:53,360 --> 00:05:55,040
user that is currently locked in.

79
00:05:55,050 --> 00:05:56,710
So why wouldn't we reuse it?

80
00:05:56,720 --> 00:05:58,580
And that's exactly what we have this code for.

81
00:05:58,820 --> 00:06:06,200
So by doing it this way, we save us so much code we would otherwise have to do this code or reuse this

82
00:06:06,200 --> 00:06:09,290
code multiple times or copy and paste it multiple times.

83
00:06:09,290 --> 00:06:15,770
So each time and the activity sign an activity then in the main activity then into my profile activity.

84
00:06:15,980 --> 00:06:19,690
But the way we do it now is we just called this function.

85
00:06:19,700 --> 00:06:21,170
It gives us the Lockton user.

86
00:06:21,380 --> 00:06:24,320
We don't need to create extra code all the time.

87
00:06:27,080 --> 00:06:32,450
I hope this makes sense, even though, of course, that would be probably a little easier to read if

88
00:06:32,450 --> 00:06:36,260
we would not do it in one one place.

89
00:06:36,260 --> 00:06:40,580
But on the other hand, if we do it in one place, it's just all there.

90
00:06:40,580 --> 00:06:40,870
Right.

91
00:06:40,910 --> 00:06:42,500
It's a little more obvious.

92
00:06:42,530 --> 00:06:44,180
Well, it really depends on what you prefer.

93
00:06:44,580 --> 00:06:45,790
OK, so let's just test it.

94
00:06:46,340 --> 00:06:55,700
Let's see if we now get Homer with the image and his email address and potentially even his phone number.

95
00:06:55,700 --> 00:06:58,490
So let's add a phone number of Homer Simpson.

96
00:06:58,490 --> 00:06:59,780
I don't know what his number will be.

97
00:06:59,780 --> 00:07:04,280
Five five five one, two, three, four, five, six, something like that.

98
00:07:04,330 --> 00:07:05,060
That's updated.

99
00:07:05,570 --> 00:07:10,010
And now the only thing that is still me is going to be the email address.

100
00:07:10,020 --> 00:07:12,310
But other than that, it's going to be Homer Simpson.

101
00:07:12,830 --> 00:07:13,820
So let's see.

102
00:07:13,970 --> 00:07:15,260
Let's go to my profile.

103
00:07:16,730 --> 00:07:23,630
And we can see there is Homer to name the email the mobile number five five five one, two, three,

104
00:07:23,630 --> 00:07:24,410
four, five, six.

105
00:07:25,910 --> 00:07:29,030
All right, at this point, we know how to load all the user data.

106
00:07:29,060 --> 00:07:31,000
We, of course, still need to update user data.

107
00:07:31,010 --> 00:07:35,990
So let's say we make changes to the mobile number or the name than we would, of course, want to be

108
00:07:35,990 --> 00:07:37,100
able to update it.

109
00:07:37,100 --> 00:07:44,210
Of course, our update button doesn't do anything as of now, but we will add functionality to our app

110
00:07:44,210 --> 00:07:45,440
in the next video, of course.

111
00:07:45,660 --> 00:07:47,240
So see you in the next one.

