1
00:00:00,150 --> 00:00:05,720
So now I am inside these main activity class and I want to actually implement this on method here.

2
00:00:05,730 --> 00:00:06,270
Right.

3
00:00:06,270 --> 00:00:11,020
First let's change the name of these arguments to view inside this method.

4
00:00:11,020 --> 00:00:16,930
I tried to create a variable of type martial arts putten so that button and here I can't say much a

5
00:00:16,930 --> 00:00:18,630
lot but an assignment operator.

6
00:00:18,630 --> 00:00:23,300
So now I want to cast this view to a martial art but an object.

7
00:00:23,310 --> 00:00:29,220
So I am 150 percent sure that I have martial art partons inside my main activity.

8
00:00:29,280 --> 00:00:32,570
My main activity actually but this view here doesn't know that.

9
00:00:32,580 --> 00:00:37,200
So the church has the to our martial art but then I truly object.

10
00:00:37,260 --> 00:00:43,590
So I can't say I can't put a lot of private practices martial or pattern here and I can just say View

11
00:00:44,080 --> 00:00:49,860
semi-hollow right in this if you are casting this view which is going to be the view the button that

12
00:00:49,860 --> 00:00:51,330
is triggering the action.

13
00:00:51,360 --> 00:00:53,680
So it is referring to an emotional button.

14
00:00:53,730 --> 00:00:59,970
So here we are just casting it to a marshal but an object and yet assigning it we are assigned to this

15
00:00:59,970 --> 00:01:00,380
value.

16
00:01:00,390 --> 00:01:07,950
But martial arts button now I can for example initialize my body but that I created in this class let

17
00:01:07,950 --> 00:01:12,410
me scroll to the top here you can see this variable here total martial arts place right.

18
00:01:12,570 --> 00:01:17,460
Let's scroll down here let's go and say this and uncle method and here I can say total martial arts

19
00:01:17,460 --> 00:01:22,400
price assignment operator total martial arts price plus added.

20
00:01:22,420 --> 00:01:25,350
I can refer to this martial art button here.

21
00:01:26,640 --> 00:01:28,550
That gets martial art.

22
00:01:28,560 --> 00:01:31,650
Price semi-colon right.

23
00:01:31,670 --> 00:01:38,130
So I think the value the current value of the total martial arts price to the value of the martial art

24
00:01:38,540 --> 00:01:43,020
martial art and that is actually interactive that is clicked or touched.

25
00:01:43,070 --> 00:01:43,690
Right.

26
00:01:43,730 --> 00:01:45,560
So and we're assigning it to this.

27
00:01:45,570 --> 00:01:52,900
Evaluate the price of that specific product that is being interactive that is being touched or clicked.

28
00:01:53,060 --> 00:01:56,570
We are actually adding that value to the value of the total price.

29
00:01:56,740 --> 00:02:01,530
And we are assigning the result of this operation to this valuable total martial arts price.

30
00:02:01,820 --> 00:02:06,940
So now after this line of course here let's actually create a new light here.

31
00:02:07,010 --> 00:02:13,910
So let's now format the martial art price here so let's create a value of type strange and the name

32
00:02:13,910 --> 00:02:21,340
of this variable is going to be martial arts place martial arts price formatted assignment operator

33
00:02:21,540 --> 00:02:29,480
can refer to this number for math class number format that get currency instance that format.

34
00:02:29,500 --> 00:02:34,210
So when I call for format here I can pass a value of type double to the format.

35
00:02:34,360 --> 00:02:41,290
MF It is and it's going to actually give us the currency instance from this life if it is going to give

36
00:02:41,290 --> 00:02:47,330
us a specific Actually the format of the price of the user's locale.

37
00:02:47,380 --> 00:02:50,040
So let's call it here and then I'm going to show you how it works.

38
00:02:50,040 --> 00:02:55,040
So let's actually pass this total Musharraf's place here to the Smurfette semi-colon.

39
00:02:55,120 --> 00:02:59,550
Let me create a new line here so that you can see what's going on here.

40
00:02:59,830 --> 00:03:01,640
Let me also create a new line here.

41
00:03:01,840 --> 00:03:08,040
So now that we have this model of the price format let's create a toast message so toast that makes

42
00:03:08,080 --> 00:03:13,720
text first we need to pass the context main activity that this come up and that we need to actually

43
00:03:13,720 --> 00:03:17,260
specify the text which is going to be martial that place.

44
00:03:17,290 --> 00:03:23,800
So Marshall Price for math so Marshall Price formatted this is going to be the takes so it is actually

45
00:03:23,800 --> 00:03:24,460
of type string.

46
00:03:24,460 --> 00:03:26,560
So it is OK to put that here come on.

47
00:03:26,680 --> 00:03:32,810
And then we need to specify the length which is going to be short data show let me create a new light

48
00:03:32,810 --> 00:03:33,350
here.

49
00:03:34,410 --> 00:03:39,330
And you've got to actually show this message this martial arts prize formatted here to the user.

50
00:03:39,450 --> 00:03:41,680
So let's run the application now.

51
00:03:41,700 --> 00:03:46,340
Let me show you the emulator so you can see that our application is running on the simulator.

52
00:03:46,350 --> 00:03:51,900
And now I want to click on this martial arts button here so you can see that the price is to follow

53
00:03:52,050 --> 00:03:52,490
right.

54
00:03:52,650 --> 00:03:55,780
If I click on it now it says $2000.

55
00:03:55,800 --> 00:04:01,110
So that's why we actually formatted our Marshall Price to that current locale.

56
00:04:01,110 --> 00:04:01,920
Right.

57
00:04:02,030 --> 00:04:06,570
You can see that here if I click on this one here this is Marshall put in here.

58
00:04:06,600 --> 00:04:08,720
Now it is $4000.

59
00:04:08,820 --> 00:04:11,730
If I click on this one now it's just $6000.

60
00:04:12,000 --> 00:04:18,780
It is actually adding the value of the Marshall Price to the current value of the total Manjunath price

61
00:04:18,870 --> 00:04:19,980
here.

62
00:04:19,980 --> 00:04:23,220
So for example this one or this one.

63
00:04:23,220 --> 00:04:29,950
So now are you going to allow the user to reset these the value of these total Marshall Price here.

64
00:04:30,030 --> 00:04:30,720
OK.

65
00:04:30,990 --> 00:04:32,310
So let's see how we can do that.

66
00:04:32,310 --> 00:04:35,820
Let's go back to android studio and let's go to this method.

67
00:04:35,880 --> 00:04:37,110
An option item selected here.

68
00:04:37,110 --> 00:04:37,620
Right.

69
00:04:37,890 --> 00:04:40,500
Let's create another case statement.

70
00:04:40,500 --> 00:04:48,220
So case our thought Id that reset just like in here is set as you can see we don't have a reset item

71
00:04:48,240 --> 00:04:49,710
here inside our menu.

72
00:04:49,710 --> 00:04:51,270
We need to create that.

73
00:04:51,270 --> 00:04:56,410
So in order to do that let's open our Android view here you just to click on view to the windows and

74
00:04:56,410 --> 00:04:57,350
then project.

75
00:04:57,360 --> 00:05:03,100
So just opened this up folder and the rest folder and here and this menu.

76
00:05:03,320 --> 00:05:06,190
Double click on this menu that underlie today in here.

77
00:05:06,300 --> 00:05:08,180
Let's add another item here.

78
00:05:08,280 --> 00:05:10,690
Let's open attacked and just happened yet idea.

79
00:05:11,250 --> 00:05:12,860
And the idea is going to be.

80
00:05:12,960 --> 00:05:20,880
So in order to specify the ID first we must pass at sign Plus Id slash and then we can actually say

81
00:05:21,030 --> 00:05:28,820
martial arts martial arts underline a priceless underline resets.

82
00:05:29,430 --> 00:05:30,240
Right.

83
00:05:30,300 --> 00:05:32,550
And then we need to specify the title.

84
00:05:32,580 --> 00:05:36,740
So here I can say reset the prices.

85
00:05:38,160 --> 00:05:43,150
Of martial arts or I can't say reset Matia that prices are reset.

86
00:05:43,200 --> 00:05:46,270
Martial arts martial arts prices.

87
00:05:46,410 --> 00:05:52,890
And finally you need to specify that sure as action if room and then itself close this tact by just

88
00:05:52,890 --> 00:05:59,610
putting a slash and then at this closing track here so that cities are IDM Let's go to our Actually

89
00:05:59,610 --> 00:06:07,050
the main activity class here and here I can't say Chase are thought Id that just they've been here reset

90
00:06:07,110 --> 00:06:09,020
Marshall marshal prices reset.

91
00:06:09,140 --> 00:06:11,140
Colin and here I can create.

92
00:06:11,220 --> 00:06:16,810
Actually we don't want to create an intent here we just want to reset the prices so I can refresh to

93
00:06:16,820 --> 00:06:23,560
is total martial arts price here and I can assign the value zero point zero to this variable.

94
00:06:23,580 --> 00:06:28,420
And finally I just need to return true from this case return to semi-colon.

95
00:06:28,600 --> 00:06:31,180
But let's run our application again.

96
00:06:31,740 --> 00:06:33,900
Let me show you the emulator.

97
00:06:33,990 --> 00:06:37,090
So here you can see that Apple is running on the simulator.

98
00:06:37,170 --> 00:06:39,640
So first let's click on this one to each box.

99
00:06:39,660 --> 00:06:41,130
Now it is $2000.

100
00:06:41,130 --> 00:06:42,270
Let's click on this one.

101
00:06:42,340 --> 00:06:43,320
$4000.

102
00:06:43,380 --> 00:06:48,080
This one $6000 and this one now is $8000.

103
00:06:48,090 --> 00:06:50,190
Now I want to reset the prices.

104
00:06:50,190 --> 00:06:55,810
So here let's just click on the ellipsis button here this dropdown menu here and now we have a new IDM

105
00:06:55,830 --> 00:06:56,310
reset.

106
00:06:56,310 --> 00:06:57,410
Martial arts places.

107
00:06:57,420 --> 00:07:03,270
If you click on it here now the prices is actually the total prices value is zero.

108
00:07:03,480 --> 00:07:05,660
So let's click on this one here.

109
00:07:05,670 --> 00:07:08,230
Now it says $2000 here right.

110
00:07:08,400 --> 00:07:11,670
If you want to you can actually just create a Toastmasters year.

111
00:07:11,910 --> 00:07:17,790
Below this item here for example for this chase or the idea that martial arts martial arts is reset

112
00:07:18,120 --> 00:07:26,620
I can't say toast that make text and that I can pass the context main activity that this come up.

113
00:07:26,820 --> 00:07:31,610
And then here for that message I can't say that I can't pass the value here.

114
00:07:31,620 --> 00:07:36,440
Total market of prices here plus two coats come on.

115
00:07:36,570 --> 00:07:42,690
And finally I can't say Len shorts that show let's run the app.

116
00:07:42,710 --> 00:07:45,230
Now let me show you the emulator.

117
00:07:45,260 --> 00:07:46,550
So here let's click on this one.

118
00:07:46,540 --> 00:07:50,200
Each box in here this one now it is $4000.

119
00:07:50,240 --> 00:07:52,500
Let's reset the prices here.

120
00:07:53,390 --> 00:07:56,580
Now it is actually showing us this value at zero point zero.

121
00:07:56,600 --> 00:07:57,450
It is now reset.

122
00:07:57,560 --> 00:08:00,410
If I click on it here again now it is $2000.

123
00:08:00,410 --> 00:08:05,000
So let's click on the dropdown menu and let's go to the Delete the marshal activity here.

124
00:08:05,210 --> 00:08:06,680
Let's delete all these.

125
00:08:06,830 --> 00:08:10,130
Actually most of the objects that we have inside our database.

126
00:08:10,280 --> 00:08:12,300
Let's click and go back here.

127
00:08:12,350 --> 00:08:17,550
Now you can see that are actually our main activity here is not updated here.

128
00:08:17,570 --> 00:08:23,450
We can see that we have still these martial art buttons here which we shouldn't have this much a lot

129
00:08:23,450 --> 00:08:24,140
of buttons here.

130
00:08:24,140 --> 00:08:26,570
There is actually a bug inside that application.

131
00:08:26,570 --> 00:08:28,360
How can we solve this problem.

132
00:08:28,370 --> 00:08:34,780
So here I want you to pause the video and then actually start debugging the application.

133
00:08:34,790 --> 00:08:40,940
According to the debugging skills that you have learned throughout this course first of all let me tell

134
00:08:40,940 --> 00:08:41,470
you that.

135
00:08:41,630 --> 00:08:43,170
Don't panic OK.

136
00:08:43,250 --> 00:08:50,270
Don't panic and just think about what's going wrong here and actually try to debug the application when

137
00:08:50,270 --> 00:08:51,070
you're ready.

138
00:08:51,140 --> 00:08:52,500
Just play the video again.

139
00:08:52,550 --> 00:08:55,740
And then here I'm going to show you what's wrong with our application.

140
00:08:55,790 --> 00:08:56,290
OK.

141
00:08:56,600 --> 00:09:00,120
So now let me tell you what is wrong with it.

142
00:09:00,170 --> 00:09:06,830
If it's your insight modify use an interface method here you can see that we here we have this IIF statement

143
00:09:06,860 --> 00:09:14,070
and here we are saying that if all martial art objects that size is actually greater than zero.

144
00:09:14,240 --> 00:09:18,950
Only in that case is going to execute the codes inside this code inside the curly braces of this if

145
00:09:19,010 --> 00:09:19,960
statements.

146
00:09:20,000 --> 00:09:25,090
So we have this line of code here scroll view that remove all views in lay out.

147
00:09:25,100 --> 00:09:31,220
So this method here is going to be executed only and only if the size of the.

148
00:09:31,220 --> 00:09:35,220
All martial arts objects are Adie's is greater than zero.

149
00:09:35,300 --> 00:09:36,210
Right.

150
00:09:36,260 --> 00:09:39,320
So we need to think about a another way in order to solve this problem.

151
00:09:39,320 --> 00:09:42,350
So here let's actually cut this kind of quick here.

152
00:09:43,190 --> 00:09:46,180
And let's put it here before this if statement.

153
00:09:46,190 --> 00:09:48,510
And below is actually released here.

154
00:09:48,530 --> 00:09:50,650
Let's put it here now.

155
00:09:50,810 --> 00:09:52,670
Let me run the application again.

156
00:09:52,670 --> 00:09:54,270
Let me show you the emulator.

157
00:09:54,320 --> 00:09:57,350
So this is our application and we have no martial arts objects here.

158
00:09:57,390 --> 00:09:57,840
OK.

159
00:09:58,040 --> 00:10:04,040
At martial arts activity here let's add a martial art here for example this time we want to teach boxing

160
00:10:04,830 --> 00:10:07,420
kickboxing the martial art price is for.

161
00:10:07,610 --> 00:10:11,470
For example one thousand dollars and the marshal of color is yellow.

162
00:10:12,510 --> 00:10:13,160
Right.

163
00:10:13,320 --> 00:10:18,380
Let's at the martial art let's for example add a bunch of martial arts you just click on the spot in

164
00:10:18,390 --> 00:10:19,040
here.

165
00:10:19,170 --> 00:10:21,270
So let's click on back button here.

166
00:10:21,270 --> 00:10:23,670
Now we have these martial arts here right.

167
00:10:23,700 --> 00:10:25,980
This monster that buttons.

168
00:10:26,010 --> 00:10:30,090
So now let's click on this ellipsis button here.

169
00:10:30,180 --> 00:10:32,610
Let's go to the delete marshal activity here.

170
00:10:32,610 --> 00:10:37,180
Now let's delete all these martial arts objects here that just click on them in order to delete them.

171
00:10:37,230 --> 00:10:44,360
Now let's go back and here you can see everything is gone and our application is working properly here.

172
00:10:44,460 --> 00:10:44,850
Right.

173
00:10:44,850 --> 00:10:45,350
Why.

174
00:10:45,360 --> 00:10:51,660
Because I am calling the Smurfette here before this if statement not inside this statement because if

175
00:10:51,660 --> 00:10:58,830
you actually for example delete all Monserrat objects then it cannot actually for example remove all

176
00:10:58,830 --> 00:11:05,340
these views here that we have inside the scroll view because this statement here this condition evaluates

177
00:11:05,340 --> 00:11:06,090
to false.

178
00:11:06,120 --> 00:11:08,850
So it's not going to execute the codes inside this statement.

179
00:11:08,910 --> 00:11:12,030
So we just put this line of code here before this statement.

180
00:11:12,060 --> 00:11:12,510
Right.

181
00:11:12,510 --> 00:11:16,770
Whenever this method is going to be called you're going to remove all the views that we have inside

182
00:11:16,770 --> 00:11:21,570
the scroll wheel and there we can actually for example look at this condition and it's a hoot.

183
00:11:21,570 --> 00:11:22,750
All these quotes here.

184
00:11:23,070 --> 00:11:25,380
So let's add another object here.

185
00:11:25,380 --> 00:11:28,110
So for example let's get behind this at martial art here.

186
00:11:28,110 --> 00:11:30,420
For example this time I want to add Judo.

187
00:11:30,420 --> 00:11:30,870
Right.

188
00:11:31,020 --> 00:11:37,870
And the martial law applies for example $5000 and martial art color here is for example green.

189
00:11:38,070 --> 00:11:38,530
Right.

190
00:11:38,640 --> 00:11:42,000
Let's add some martial arts here to our database.

191
00:11:42,000 --> 00:11:46,340
If I recall back here you can see that we have these patents here.

192
00:11:46,350 --> 00:11:49,590
Now I can go to the for example did Monserrat here.

193
00:11:49,620 --> 00:11:53,320
I can delete some of them if I can you can go back here.

194
00:11:53,400 --> 00:11:59,820
Now you can see that it is actually the updated view is updated properly and it works fine.

195
00:11:59,820 --> 00:12:00,780
So that's it.

196
00:12:00,780 --> 00:12:06,780
This is our application this is the end of this app and I hope that you have learnt a lot of concepts

197
00:12:06,980 --> 00:12:08,380
actually about a school.

198
00:12:08,400 --> 00:12:14,960
You have mastered if you have finished this apps up until this actually does part.

199
00:12:15,300 --> 00:12:20,300
You have finished actually mastering a skill light in Android.

200
00:12:20,310 --> 00:12:23,190
You are now actually askew like master.

201
00:12:23,220 --> 00:12:30,030
Make sure to create applications of your own and use as a light database in your own applications in

202
00:12:30,030 --> 00:12:36,600
order to actually just practice on these very helpful skills very precious skills.

203
00:12:36,600 --> 00:12:37,830
Thank you very much for watching.

204
00:12:37,830 --> 00:12:42,360
If you have any questions please post the discussion in the course and then I'll do my best to answer

205
00:12:42,390 --> 00:12:44,040
all of your questions.

206
00:12:44,040 --> 00:12:48,670
So I'm going to create some more actually application some more awesome applications.

207
00:12:48,930 --> 00:12:50,720
And I'm going to add them to the course.

208
00:12:50,810 --> 00:12:53,370
So make sure to actually stay tuned.

209
00:12:53,610 --> 00:12:55,050
I will add them to the course.

210
00:12:55,050 --> 00:12:59,400
I will add some new tutorials in order to create some production the applications.

211
00:12:59,400 --> 00:13:00,410
Thank you very much for watching.

212
00:13:00,420 --> 00:13:01,640
And as I said earlier.

