1
00:00:00,530 --> 00:00:05,790
Welcome back and this video, we are going to solve an issue that we still have and we're also going

2
00:00:05,790 --> 00:00:09,430
to prepare the activity that we are going to need for the next video.

3
00:00:09,750 --> 00:00:14,550
So one thing that we currently have is once we add a new entry here.

4
00:00:16,260 --> 00:00:18,180
So I'm going to call this one test five.

5
00:00:21,260 --> 00:00:25,310
And I'm going to add an image here to select one from the gallery.

6
00:00:29,440 --> 00:00:32,170
Let's use humor here once again.

7
00:00:34,440 --> 00:00:41,040
Let's save this, we go back and see the place was at it, but it's not in this list, so this green

8
00:00:41,040 --> 00:00:45,830
is not being notified about that and that is something that we still need to implement.

9
00:00:45,840 --> 00:00:51,780
So let's fix that first and then we are going to add the activity that will open up later on once we

10
00:00:51,780 --> 00:00:54,780
click one of those elements here.

11
00:00:55,530 --> 00:00:55,920
All right.

12
00:00:55,920 --> 00:00:57,730
So let's go ahead and do that.

13
00:00:57,900 --> 00:01:04,709
So the first thing we need to do now start an activity for result, because currently what we do is

14
00:01:04,709 --> 00:01:08,340
we only start in activity, but we actually want to have a result here.

15
00:01:08,670 --> 00:01:11,070
So I'm going to add four result.

16
00:01:11,490 --> 00:01:14,090
And if you do that, then you need to pass an integer.

17
00:01:14,670 --> 00:01:17,160
So we need to add something else here.

18
00:01:17,490 --> 00:01:26,060
And I'm going to call this integer add underscore place on this core activity request code.

19
00:01:26,760 --> 00:01:27,180
All right.

20
00:01:27,180 --> 00:01:27,960
And this will be.

21
00:01:30,070 --> 00:01:34,600
Another static variable that I need, so I need to have a companion object here.

22
00:01:36,310 --> 00:01:38,290
Companion object.

23
00:01:41,800 --> 00:01:46,750
And I'm going to create this variable here, which I'm going to assign the world you want to so far

24
00:01:47,200 --> 00:01:49,460
at your request, code one.

25
00:01:50,380 --> 00:01:53,620
Now we can go ahead and go to our ad Happy Place activity.

26
00:01:53,830 --> 00:01:59,860
And here inside of our button, click so on button safe.

27
00:02:01,510 --> 00:02:07,930
We check if happy place or if I'd place Krater zero at that point, currently we just display.

28
00:02:08,840 --> 00:02:11,690
A toast where we say a happy place.

29
00:02:12,760 --> 00:02:19,990
Details are inserted successfully, so instead of doing that, I want to set the result, so I'm just

30
00:02:19,990 --> 00:02:21,370
going to say activity.

31
00:02:21,830 --> 00:02:23,740
The result is OK.

32
00:02:25,680 --> 00:02:26,340
Because now.

33
00:02:27,500 --> 00:02:34,070
Our main activity since the activity for results, so it starts out here, start activity for resolve

34
00:02:34,520 --> 00:02:40,160
and it sends the number here, which is our ad happy place activity request code.

35
00:02:40,490 --> 00:02:47,000
And then in our ad heavy place activity there, at the point where we save it, we can say, OK, the

36
00:02:47,000 --> 00:02:48,610
result is that it's OK.

37
00:02:49,430 --> 00:02:55,600
So now we can go ahead back to our main activity and implement our own activity result.

38
00:02:56,360 --> 00:03:00,740
So here are right on activity result.

39
00:03:03,820 --> 00:03:12,190
And what I want to do here is I want to check if the request code that we sent was this one here, our

40
00:03:12,340 --> 00:03:14,200
had place activity request code.

41
00:03:14,230 --> 00:03:18,970
So if request code is equal to.

42
00:03:20,180 --> 00:03:22,730
Had police activity request code.

43
00:03:25,140 --> 00:03:32,970
Then I want to check if the result code is equal to activity dot result.

44
00:03:33,050 --> 00:03:33,750
OK.

45
00:03:36,420 --> 00:03:45,390
And then I want to call my get happy place from database or from local database, so this is this.

46
00:03:46,560 --> 00:03:53,070
Function that we created here, which gives us all of the happy places, right, and we, so to speak,

47
00:03:53,070 --> 00:03:53,970
refresh it here.

48
00:03:54,610 --> 00:03:54,810
Right.

49
00:03:54,900 --> 00:04:02,100
And otherwise I can just write a log here, log e activity.

50
00:04:04,880 --> 00:04:07,520
And the message will be canceled.

51
00:04:10,220 --> 00:04:12,950
Or back pressed.

52
00:04:14,060 --> 00:04:20,029
Because of the user prospect, for example, then he didn't create a new entry, so we don't need to

53
00:04:20,149 --> 00:04:24,620
call this get happy place this list from local database, which will then.

54
00:04:25,830 --> 00:04:32,370
Refresh everything, as you can see, so it gets everything and then it sets everything up, so especially

55
00:04:32,370 --> 00:04:37,210
this set up, happy place, recycled view, which sets up the result of you with the latest data.

56
00:04:37,230 --> 00:04:40,230
That's where we are currently lacking.

57
00:04:41,340 --> 00:04:46,110
All right, now we can test this again, all right, so that we are you can see test five now is there?

58
00:04:46,110 --> 00:04:47,760
But that's not what we wanted to test.

59
00:04:47,770 --> 00:04:51,110
We want to see if test six is going to be there.

60
00:04:53,330 --> 00:05:01,010
And I'm going to add an image here from gallery again, because it's quicker, so let's take this image.

61
00:05:01,760 --> 00:05:05,090
It's safe and we can see it's there directly.

62
00:05:05,810 --> 00:05:06,470
All right, perfect.

63
00:05:06,470 --> 00:05:11,540
So that is exactly what we wanted, because maybe you were testing your application before and you realized,

64
00:05:11,540 --> 00:05:13,280
oh, man, it's updating the list.

65
00:05:13,280 --> 00:05:14,840
So something must have gone wrong.

66
00:05:15,050 --> 00:05:19,490
But that's just because we haven't implemented the feature yet and now you know how to implement it

67
00:05:19,490 --> 00:05:20,930
and why it's important to do so.

68
00:05:23,260 --> 00:05:28,390
This could have been a super short video, but I think it makes sense to add something else for the

69
00:05:28,390 --> 00:05:33,190
next video in preparation, because what we are going to require is a new activity.

70
00:05:34,590 --> 00:05:40,080
That will open up once we click on any of those elements here.

71
00:05:40,830 --> 00:05:44,370
All right, so let's prepared let's create a new activity here.

72
00:05:46,740 --> 00:05:50,330
New activity is an empty activity here.

73
00:05:52,020 --> 00:05:54,000
And I'm going to call this one happy.

74
00:05:56,790 --> 00:06:05,370
Place detail activity for now, the only two things that I'm going to do is I'm going to go to the manifest

75
00:06:05,370 --> 00:06:11,040
and set that activity up, that it looks the same as our others, which means it has the same theme

76
00:06:11,040 --> 00:06:13,540
and it has the same orientation.

77
00:06:14,340 --> 00:06:16,860
So here for this activity here.

78
00:06:18,330 --> 00:06:20,780
Go to had the code here.

79
00:06:22,700 --> 00:06:25,890
And that one will be called a little different.

80
00:06:25,910 --> 00:06:29,380
So here it will be a happy place.

81
00:06:29,390 --> 00:06:30,050
Details.

82
00:06:34,270 --> 00:06:36,070
And later on, we can change that label.

83
00:06:38,260 --> 00:06:46,120
And then we need to import our here because our R is in a different bundle or in a different directory,

84
00:06:46,120 --> 00:06:49,890
so we need to import that real quick and our happy place detail activity.

85
00:06:50,590 --> 00:06:56,230
And then the final thing that I want to do for this video is to add something to the layout, which

86
00:06:56,240 --> 00:07:00,070
will just be the bar at the top.

87
00:07:00,610 --> 00:07:01,480
So here.

88
00:07:02,660 --> 00:07:04,190
Had a happy place.

89
00:07:05,770 --> 00:07:11,260
Let's go to the code and here we are, the toolbar, so I'm just going to copy this toolbar here because

90
00:07:11,260 --> 00:07:13,570
I want to use the same toolbar in my.

91
00:07:15,070 --> 00:07:17,010
Happy place detail activity here.

92
00:07:18,960 --> 00:07:20,730
And I'm going to call this one.

93
00:07:23,140 --> 00:07:24,400
Heavy police detail.

94
00:07:25,630 --> 00:07:31,000
All right, so we're not going to be able to see that yet, but we're going to add that in the next

95
00:07:31,000 --> 00:07:31,410
video.

96
00:07:31,420 --> 00:07:32,400
So see you there.

