Hey there.
Well let's get down to implementing the behavior of our application to do this.
Let's go to main activity.
Let's remove the unnecessary code.
The previous one and then we will create private fields and the first private Sigmar I will call it
Sig bar and proud text to
TextView
and then we will bind all out Sigma aside fine view by D I.D. Sig bar
and text to assign fine view by I.D.
I.D. the text to you next.
Now we need to set the maximum for our Sig bar to do this.
All right Sig bar set Max set for example 10 minutes.
This is 600 seconds.
Next said the progress for sig but we want to set the timer to 60 seconds by default.
So we will do Sig bar set.
Progress and specify here 60 seconds and next we need when they're changing the position of our run
it changes our texts.
Therefore we need to install Sig bar set on Sig bar change listen a specify new Sig bar on Sig bar change
listen.
And androids to the.
Creates a new anonymous class for us with methods that we must override.
And so we first need to get the minutes and seconds.
Paul will text you to do these.
Let's declare the new variables the first INT mean it's
and assign it the value of our progress progress divided by sixty seconds.
That is if we have one hundred twenty seconds in progress then we will have one hundred twenty one divided
by 60 Minutes.
We have two minutes if one hundred eighty.
Well then three minutes.
And so if we have not an
integer division or result for example we have one hundred twenty five and divided by six there will
be two and there will be some decimal places through that point.
But since we have that mean it's chilly in of an integer type this sites will be automatically discarded
and 0 minutes will be around it and then we needs the we need seconds they are calculated in the following
way in seconds and we stopped the subs tracked from our
progress mean it's times 60
and now we need to set these values in our text.
But there is one thing.
And the fact is that we have double digit numbers for minutes and seconds.
And if they mean it's less than 10 or the seconds is less than 10 then that number will consist of one
digit.
And so that we have the same two digits interface we need to take this into account in our code.
Let's start by creating two variables over the string type string.
Mean it's string
set for to start the empty string and also string second string and empty string assented
and then we check if mean it's less than 10.
And then we said mean it's string to zero and then concatenate with our variable mean it's else.
In another case
a sign they mean it's string.
You can buy the specified like this or string value of
minutes
and do the same four seconds a seconds
less than 10
second string a sine
0 plus seconds
else
second string a sine string value of
seconds and further we say it in our text to these values text to set text ministering plus
column and plus second string
and now let's try to run the application and check what we get
and also see the value changes when you drag and even the second or a minute value less than 10 is displayed
zero.
The first
and we can change it to 10 minutes.