1
00:00:01,170 --> 00:00:03,300
Hello this is Martez or Corddry.

2
00:00:03,390 --> 00:00:07,660
And in this story are you going to work on the expanded view.

3
00:00:07,890 --> 00:00:13,240
First of all as you can see I am inside these uncreate Smurfette and here before the ending really of

4
00:00:13,290 --> 00:00:19,210
this Meffert I am inside is uncreate me and I am going to access the expanded view.

5
00:00:19,230 --> 00:00:21,540
So Vinita create a valuable first.

6
00:00:21,690 --> 00:00:22,680
It's going to be final.

7
00:00:22,740 --> 00:00:24,370
So it cannot be changed later.

8
00:00:24,390 --> 00:00:27,060
The value of this variable cannot be changed.

9
00:00:27,420 --> 00:00:36,000
And the hype is going to be View and The name is going to be expanded view expanded view assignment

10
00:00:36,000 --> 00:00:36,740
operator.

11
00:00:37,020 --> 00:00:49,070
Lets refer to our widget floating widget dot find view by id r that Id got expanded view semicolon.

12
00:00:49,500 --> 00:00:51,190
Now we can access.

13
00:00:51,210 --> 00:00:57,250
Let me show you the emulator there while we have this live image.

14
00:00:57,490 --> 00:01:00,910
So I am going to create an unclick listener for this lion image.

15
00:01:00,910 --> 00:01:03,060
First we need to access this image.

16
00:01:03,370 --> 00:01:08,260
So let's say that we are going to have an image view image view.

17
00:01:08,260 --> 00:01:16,020
Its name is going to be like an image assignment operator.

18
00:01:16,270 --> 00:01:18,720
So let's cast it to an image view.

19
00:01:19,640 --> 00:01:21,330
Find view ID.

20
00:01:21,590 --> 00:01:25,920
Excuse me we need to refer to our visit first floating which it does find view.

21
00:01:26,070 --> 00:01:32,930
Id artist Id that lion image semicolon.

22
00:01:33,140 --> 00:01:41,680
Now we can see like an image that sits on a click listener and we need to pass the context.

23
00:01:41,690 --> 00:01:45,980
So the context is the service fluting View service

24
00:01:49,840 --> 00:01:54,940
with Capitol floatable So we start this.

25
00:01:55,090 --> 00:02:07,350
Now we can go inside is unclear Smurfette after this break statement we can say case our ID that lion

26
00:02:07,410 --> 00:02:19,450
image call let's create a Toastmasters let's say TOSed make text fluting your service Carmo the text

27
00:02:19,450 --> 00:02:22,210
is going to be like when is tapped

28
00:02:25,260 --> 00:02:31,380
Khama the screen to be sure it's Daut show.

29
00:02:31,420 --> 00:02:36,050
So let's create a new line and then break.

30
00:02:36,080 --> 00:02:40,960
So let's go back to our uncreate and then let me show you the emulator.

31
00:02:41,150 --> 00:02:46,850
So we're going to create a listener or click listener for this previous spot.

32
00:02:47,060 --> 00:02:57,440
So here I am going to say that we have again an image for you so its name is going to be Previous button

33
00:02:58,470 --> 00:02:59,920
assignment operator.

34
00:03:00,090 --> 00:03:06,600
Its name is going to be is really the classic 20 minute view object floating widget that find fine view

35
00:03:06,690 --> 00:03:16,390
ID or the ID that previous Pythian previous semicolon.

36
00:03:16,390 --> 00:03:23,290
So if you know how to proceed from now on you can actually just skip the video but I'm going to code

37
00:03:24,130 --> 00:03:29,640
this and create it here manually or you can just copy and paste.

38
00:03:29,710 --> 00:03:30,780
A good idea.

39
00:03:31,240 --> 00:03:39,900
So let's say that we have a previous button that sits on click listener and ave to pass the context.

40
00:03:39,910 --> 00:03:49,890
So floating your services Capitol that this an ongoing site is an effort and we can't say case

41
00:03:52,740 --> 00:03:55,530
art that Id dot.

42
00:03:55,840 --> 00:04:04,360
So when this refer to the idea that the idea is pity previous call and so let's copy this message here.

43
00:04:05,290 --> 00:04:07,100
And pasted here.

44
00:04:07,360 --> 00:04:19,610
So the value is going to be here instead of lawyer type in here previous button is tath and then bridge.

45
00:04:20,020 --> 00:04:20,700
OK.

46
00:04:20,950 --> 00:04:22,620
So let's go into this.

47
00:04:22,620 --> 00:04:24,420
Uncreate method here again.

48
00:04:24,480 --> 00:04:25,840
So let me show the emulator.

49
00:04:25,840 --> 00:04:28,450
We have this Leppert image.

50
00:04:28,450 --> 00:04:33,750
So now let me just copy these two lines of code here.

51
00:04:34,630 --> 00:04:40,120
Let's paste it here so that we have the Leppert Emmets

52
00:04:42,650 --> 00:04:43,660
here.

53
00:04:43,800 --> 00:04:51,790
You're going to access the first image and we need to say Leffert image that unclick the center and

54
00:04:51,790 --> 00:04:58,130
we pass the context so here we are going into a can copy this case and paste it here.

55
00:04:58,690 --> 00:05:03,560
So now we are going to see our leopard image.

56
00:05:03,610 --> 00:05:10,490
So here it is a leopard image is clicked.

57
00:05:10,510 --> 00:05:12,320
So let's use a capital L.

58
00:05:12,760 --> 00:05:17,720
Let's go back to the uncreate and then we have the next button.

59
00:05:18,100 --> 00:05:22,630
So here we are going to copy and paste these two lines of code here.

60
00:05:24,570 --> 00:05:28,810
So the name is going to be next.

61
00:05:29,740 --> 00:05:31,210
Button.

62
00:05:31,740 --> 00:05:35,740
So here we are going to refer to the next path in between.

63
00:05:35,840 --> 00:05:39,310
Next we're going to see the next button.

64
00:05:39,570 --> 00:05:41,640
Then click the center and the context.

65
00:05:41,670 --> 00:05:46,170
So let's copy and paste this case here.

66
00:05:47,510 --> 00:05:49,440
And the value is going to be next.

67
00:05:49,550 --> 00:05:51,770
But in between next.

68
00:05:51,770 --> 00:06:04,900
So here we are going to see that the next button is tapped next button is tapped right.

69
00:06:05,040 --> 00:06:07,980
So let's go back to the uncreate method here

70
00:06:11,180 --> 00:06:13,200
let me show you the emulator.

71
00:06:13,430 --> 00:06:20,430
So now we have these two buttons the close button and the open image.

72
00:06:20,740 --> 00:06:23,060
So lets access the close button.

73
00:06:23,480 --> 00:06:28,100
Let's say that we have an image view and its name is going to be expanded.

74
00:06:28,280 --> 00:06:39,920
Close but it expanded close button assignment operator let's cast it to an image view finder view floating

75
00:06:39,920 --> 00:06:52,230
widget floating widget that fine view Id artist Id that expanded close in close with an expanded semicolon.

76
00:06:52,240 --> 00:06:55,550
So let me create a new line so that you can see whats going on here.

77
00:06:55,870 --> 00:06:58,120
And then we need to create that unclick listener.

78
00:07:01,560 --> 00:07:09,140
Expanded the close button expand think the set on click listener and the context is going to be floating.

79
00:07:09,140 --> 00:07:16,860
You said that this on here inside these on click it again you can actually create a case.

80
00:07:16,930 --> 00:07:19,880
So let me copy and paste this one here.

81
00:07:21,110 --> 00:07:30,230
So kickstarted I did that expanded close to close but then expanded and here at the value the name is

82
00:07:30,230 --> 00:07:33,000
going to be expanded.

83
00:07:35,500 --> 00:07:40,490
Close but then is tapped.

84
00:07:40,550 --> 00:07:42,050
So let me create a new line

85
00:07:44,810 --> 00:07:45,710
now.

86
00:07:45,800 --> 00:07:53,690
Finally are going to actually create a listener and click listener for this of an image.

87
00:07:53,780 --> 00:08:02,560
So here we can say make get inside this and create an image view or pin button.

88
00:08:03,540 --> 00:08:09,590
Assignment operator lets just to add an image of you object floating rigid.

89
00:08:09,610 --> 00:08:10,790
Thats fine.

90
00:08:10,810 --> 00:08:20,510
Id art that Id dot or pin button semicolon that say Open button that certain click listener.

91
00:08:21,050 --> 00:08:26,010
And really to pass the context which is going to be floating your service that this and ready to go

92
00:08:26,010 --> 00:08:36,740
inside this unclick effort here below this case you're going to say case bar that's ID dot open button.

93
00:08:36,770 --> 00:08:47,210
Colin posts that make text that make text the context fluting Youth Service that this come up and the

94
00:08:47,210 --> 00:08:52,700
text is going to be open image is tapped.

95
00:08:54,460 --> 00:09:02,530
And finally you need to specify the duration of this message thats short show.

96
00:09:02,670 --> 00:09:04,110
So let me create a new line here.

97
00:09:04,110 --> 00:09:07,360
And finally we need to put the brakes statement here break.

98
00:09:08,130 --> 00:09:16,530
So that sort of we created all of these our listeners for all of the components of our expanded state

99
00:09:16,530 --> 00:09:17,830
here.

100
00:09:17,850 --> 00:09:20,500
So now let me show you the emulator here.

101
00:09:20,860 --> 00:09:28,590
And then the user Papps for clicks and this close button here the collapsed view is going to be shown

102
00:09:28,590 --> 00:09:29,500
to the user.

103
00:09:29,850 --> 00:09:37,190
And when the user clicks and this open image often button here the main application is going to be open

104
00:09:37,190 --> 00:09:38,400
to the main activity.

105
00:09:38,460 --> 00:09:39,100
Right.

106
00:09:39,450 --> 00:09:42,350
So let's go back to the Android studio here.

107
00:09:42,660 --> 00:09:49,020
Let's go and it is unclear if it when the user clicks or taps undisclosed button expand expanded.

108
00:09:49,200 --> 00:09:52,710
I want the collapsed view to be visible.

109
00:09:52,860 --> 00:09:57,570
And I want the expanded view to be gone.

110
00:09:57,570 --> 00:10:04,440
So inside this Arncliffe effort and inside this case are that ID that close button expanded after this

111
00:10:04,440 --> 00:10:06,490
TOSed message here.

112
00:10:06,870 --> 00:10:11,700
I need to refer to the collapsed view but I cannot do that here.

113
00:10:11,700 --> 00:10:13,410
Here I am inside another method.

114
00:10:13,420 --> 00:10:15,580
Unclear if it but the collapsed view.

115
00:10:15,630 --> 00:10:22,260
Let me scroll to the top inside this on creating of it the collapsed view is actually created inside

116
00:10:22,260 --> 00:10:28,860
is uncreate me and I cannot access this variable in from our uncollectable for it.

117
00:10:29,250 --> 00:10:32,300
So there is a problem here how to solve this problem.

118
00:10:32,640 --> 00:10:35,950
Now we can actually pause the video and solve this problem.

119
00:10:36,200 --> 00:10:42,410
But on your own and if you cannot do that you can actually play the video.

120
00:10:42,420 --> 00:10:45,540
But I'm going to solve the problem now here.

121
00:10:46,080 --> 00:10:52,850
You can actually say that we have this valuable here Club collapse view inside this and create it.

122
00:10:53,220 --> 00:10:56,400
But let's keep it this value here.

123
00:10:56,450 --> 00:10:58,110
Final view collapsed.

124
00:10:58,140 --> 00:11:04,290
Let's scroll up and let's declare this valuable insight is class float floating view service and let's

125
00:11:04,290 --> 00:11:05,600
place this value here.

126
00:11:05,650 --> 00:11:09,000
Cynical but there is a problem here.

127
00:11:09,360 --> 00:11:15,500
The Instance variables or the valuables that are declared inside the class cannot be fined.

128
00:11:16,490 --> 00:11:17,060
OK.

129
00:11:18,080 --> 00:11:23,300
And this means that this final here should be deleted.

130
00:11:23,420 --> 00:11:29,380
So now that we actually declare this variable here inside this class we can scroll down here.

131
00:11:29,870 --> 00:11:32,060
So we have this final view.

132
00:11:32,240 --> 00:11:35,050
It's actually the final view collapsed view.

133
00:11:35,090 --> 00:11:42,980
You can see that here right now it's this final and view because now this collapsed view refers to our

134
00:11:43,040 --> 00:11:49,720
instance variables to this collapsed view variable that is actually declared inside this floating View

135
00:11:49,730 --> 00:11:58,980
service which can do the same thing for the expanded view we can see view and the name is going to be

136
00:11:59,070 --> 00:12:04,660
expanded view semicolon right now.

137
00:12:04,770 --> 00:12:05,990
Let's scroll down here.

138
00:12:06,030 --> 00:12:08,700
Let's find the expanded view of our table.

139
00:12:08,700 --> 00:12:09,690
So here it is.

140
00:12:09,910 --> 00:12:13,950
Final view expanded you right now let's delete the view and the final.

141
00:12:14,220 --> 00:12:18,430
So that is expanded view here actually refers to an instance variable.

142
00:12:18,430 --> 00:12:22,640
Expand that view that is declared inside this floating Bucephalus class.

143
00:12:22,710 --> 00:12:24,050
Let's scroll down here.

144
00:12:24,240 --> 00:12:31,850
Now we can go inside this unclever fed and for this case are that ID that close but an expanded third

145
00:12:32,000 --> 00:12:33,170
is Toastmasters.

146
00:12:33,270 --> 00:12:35,190
I can't say collapsed view

147
00:12:38,140 --> 00:12:45,560
that set visibility view but visible OK.

148
00:12:45,930 --> 00:12:51,610
And we need to actually close the expanded view so we can see a expanded view.

149
00:12:51,690 --> 00:13:02,210
That said visibility view that's gone now we can see that when they close button is clicked the class

150
00:13:02,390 --> 00:13:06,870
the collapsed view is going to be shown to the user and the expanded view is going to be gone.

151
00:13:07,250 --> 00:13:11,760
And let's go for inside this case or that I did not open water.

152
00:13:11,990 --> 00:13:14,820
Now we need to create an Internet first.

153
00:13:14,940 --> 00:13:26,800
Actually say intent and the name is going to be open up intent assignment operator new intent context

154
00:13:26,800 --> 00:13:36,150
which is going to be a floating view service that this and we need to actually refer as a signal we

155
00:13:36,150 --> 00:13:38,910
need to refer to the class that we want to move to.

156
00:13:38,920 --> 00:13:41,160
We want to transition to another class right.

157
00:13:41,200 --> 00:13:47,810
So this is going to be main activity that class and finally leaving it with a semicolon at the end of

158
00:13:47,810 --> 00:13:48,790
our statement.

159
00:13:49,010 --> 00:13:52,380
Let me create a new line so that you can see what's going on here.

160
00:13:52,790 --> 00:13:58,830
So now we have this intent now Vinnie to actually add a flag to this intent.

161
00:13:59,000 --> 00:14:09,160
Let's say that we have the open app intent but at Flack's and the flags that we want to use here is

162
00:14:09,170 --> 00:14:11,080
going to be new.

163
00:14:12,050 --> 00:14:16,160
Activity and flag activity new task cynical.

164
00:14:16,170 --> 00:14:23,110
So we used this flag here because of duplicity problems up here.

165
00:14:23,120 --> 00:14:29,540
If you don't specify it is like for this intent for this app intent here then there are going to be

166
00:14:29,540 --> 00:14:36,230
two instances of the main activity class and we may actually wind up with memory problems and that's

167
00:14:36,230 --> 00:14:40,110
not good that's not a good programming practice.

168
00:14:40,130 --> 00:14:46,780
So here instead of sort of creating two activities we decided to use this solution.

169
00:14:47,030 --> 00:14:52,640
And by using this flag only one instance of the main activity is going to be created when the service

170
00:14:52,640 --> 00:14:53,730
is actually stopped.

171
00:14:53,790 --> 00:15:02,620
When we want to actually start the service and move to the main activity and here they start activity

172
00:15:04,240 --> 00:15:08,680
and we just need to pass the open intent.

173
00:15:08,710 --> 00:15:12,200
Finally we need to say stop self in order to stop the.

174
00:15:13,560 --> 00:15:16,560
OK so that's it that's enough for this tutorial.

175
00:15:17,100 --> 00:15:25,560
And in the next story all we're going to specify how to track the widget over the other views how to

176
00:15:25,550 --> 00:15:31,860
try to get it over our screen by using the Tochtli center.

177
00:15:31,860 --> 00:15:33,410
So thank you very much for watching.

178
00:15:33,450 --> 00:15:39,180
If you have any questions about these concepts that you've learned so far please post the discussion

179
00:15:39,180 --> 00:15:42,940
in the course and then I'll do my best to answer all of your questions.

180
00:15:43,500 --> 00:15:44,940
Thank you very much for watching.

181
00:15:45,180 --> 00:15:48,430
And I look forward to seeing you in the next story.

