And now we need to create another handler for this.
But as you can see here inside is uncreate Mefford.
We put this value here.
So now inside this main activity class after the end in calibers of these of these PDT suddenly change
takes water handler.
Now I'm going to actually paste in some lines of code here in this class.
So make sure that you are actually inside this main activity class before this and in Kurla place of
this main activity class and then actually paste in some lines of code here.
So as you can see here these are lines of code that I pasted here and now I'm going to explain to you
what's going on here.
Exactly.
First of all as you can see we have this handler and the access modifier of this handler is private.
This handler is final which means this is actually a constant.
And then as you can see the data type of our handler is actually switchboard dot and see part change
listener interface.
Right.
And the name of our handler is 6 bar savings per cent change the center assignment operator.
And here I am actually creating an anonymous inner class that actually implements this on the part change
in an interface and then it needs to actually implement the methods that are inside of that interface.
So for example we have this unprogressive change team effort on start tracking touch and unstop tracking
touch of which we don't need these.
If it's here in inside our application inside our main activity class but because we are implementing
this on each part change the center interface we need to overwrite them.
OK.
So let's go inside is our progress changed Smurfette.
That actually happens when a user for example is actually working on this switchboard here.
Right.
When I actually see what is actually its value is actually changed.
This method is going to be called on progress changed and this if it accepts free arguments the first
one is C.P.R. as you can see here to see what object that we have here.
The second one is the progress.
So for example when we are sitting on the seat bar it can actually return a value an integer value.
And then we can actually get that value by actually by referring to this argument.
And here we have this from use a boolean.
So it's going to determine whether this sequel is actually changed by the user or it is actually changed
by the logic of the application.
So here for this application we just want to.
Because for this application it doesn't really matter how this argument is being used because when the
user is changing this sick bar we can actually determine how the logic is going to be performed here.
So now let's go inside this unprogressive method here.
And first of all are you referred to the name of this savings per cent variable.
So now let's go inside.
Our main activity class here as you can see I actually created this valuable here inside our class savings
percent assignment operator 0.25.
So I actually created this value bet and the data type of this variable is double double.
And then this this is the value the decimal value that I assigned to this variable initially.
So now as you can see here inside our unprogressive if I actually referred to the name of that valuable
savings percent.
So this variable is going to hold the value of this percent right.
Assignment operator.
So here you referred to the name of this progress here the value that we actually get from this actually
from Sikking is seeking on the seaboard divided by 100.
So this was actually sitting on the seat while you are going to actually get an integer value.
But because we need actually we need to convert that value to a percent.
We need to devote that value by 100 so that we get actually a person's value and then we can assign
that value to the savings percent.
So now we have the savings percent and now I would actually create another Meffert in order to calculate
the savings.
OK.
We need to calculate the savings according to the salary that they use if for example enters inside
this it Etisalat here and then according to this search bar for example the user wants to save 30 percent
income and then we can actually Chatroulette is money saved here.
So now after the end in curly brace of this listen of this handler here I am actually pasting some lines
of code here in say this main activity class and then I'm going to explain to you what's going on here.
Exactly.
So as you can see here these are the lines of code that I pasted here.
And as you can see the access modify of this method is actually private the return type of this method
is Voyt and the name of the Smif it is calculated savings right.
And this method actually accepts no arguments.
So let's go inside the curly braces of the Smurfette Let's go inside the body of this Meffert And let's
see what's going on here.
First of all I am actually setting the text of this text the same person.
So now if you look at this your here if you look at our application here I am actually setting the text
of this to the safe percent so excessive percent of set text per cent format's value that format.
So here we are referring to it to our person formats about objects that we actually created inside our
main activity class in life 16 as you can see here.
I created this object is in order to actually get the specific format of actually of the person character
according to the specific locale in the user's device.
Right.
So that's why I actually created this object per person format's value that format saving's percent.
So again I'll refer to the name of this valuable that actually holds the value of the person.
So for example when the user is actually C-Change on the search bar that this value is going to hold
that value by percent.
And then here we are again setting the stage see the setting is the text of this thing is a percent
actually referring to the name of that variable.
So now here in line 212 as you can see we created another variable which is of type double.
And the name of this value that is saved money.
OK.
So it's going to calculate the savings according to the use of a salary and how much he wants.
He or she wants to actually save his or her income and then it's going to actually hold this value so
double saved money assignment operator.
So as you can see here we have an operation here inside the parentheses.
So here because there is only one operation we can actually eliminate these practices as you can see
here.
So total salary.
So here you referred to the name of the salary to the value that that the user actually assigned to
the as it takes here.
So if you look at this say this main activity class I actually created this total salary here inside
this class and inside the Smurfette insight is actually EDT salary change takes to watcher.
And inside these on takes change method here as you can see I am assigning the value that the user is
actually enter is entering into this text right here.
I am actually getting disvalue here.
I am actually converting this value to a string value.
And then here I am converting this value to a double value and then we can assign that value to the
total salary value.
Right.
So let's go back to our calculate saving method here.
So total salary.
Multiply it by savings percent.
So in this way we can actually get the value.
Actually the amount of money that the user wants to save and then we can actually assign that value
to the saved money.
OK so total salary multiplied by savings percent this value that the user enters inside is ediface multiplied
by the value that the user for example wants to save.
For example 30 percent or 50 percent or 100 percent.
And then now as you can see by multiplying these two values together we can achieve the save the money
and in line.
Two hundred and fourteen Here now is the time to actually set the text of the stakes here.
So th the money saved that's a text currency format value that format.
And again we created this object currency format's value inside our main activity class here as you
can see in order to get to the specific format of the value that is actually specific to the split locale
that is inside of the user's device.
Okay.
So now here currency format value does for them and save the money as you can see here.
So here now we can actually as scientists save the money to this takes a view here.
So now we need to actually call this method here inside our first of what insight is on progress changed
Mefford that is inside of this handler inside of these anonymous inner class.
So after this line of thought here inside is unprogressive imperfect we need to actually just call this
calculate savings here and here after this line of code here inside these on takes the change Smurfette.
For example when the user enters a value here I just need to put these Meffert here Chad Chatroulette
savings and in this way we can actually calculate the savings.
And now it's time to actually run our project and see what happens.
So here as you can see our application is running on this emulator.
So now you want to assign a value here into these EDT salary.
So for example the user ends five thousand dollars a month.
Right.
So now let me actually disappear this keyboard here and now as you can see if the user wants to save
25 percent of his or her income this is the value that is actually saved.
Right.
So all the user for example wants to save 50 percent of his or her income.
This is the value that the user should save.
Write or if the user wants to for example save 100 percent of his or her income this is the value that
the user should save.
So hopefully that makes sense.
And this is actually a completely perfect application.
You can work on this application or you can actually for example put a scroll view here and then you
can put some other some lots of different actually calculators inside that scroll view and then you
can actually put your own logic here.
And then you can just uploaded this application to the Google Play store and make application your own.
So thank you very much for watching and hopefully this application was very helpful to you.
I actually got lots of and lots of different features of Android to you.
So make sure to work on these skills and make sure to master these skills that I taught you in this
tutorial.
Thank you very much for watching.
And by the way if you have any questions about the concepts that I actually caught you in the lesson
please post the discussion in the course and then I'll do my best to answer all of your questions.
Again thank you very much for watching and I'll see you in the next year Tauriel.