We'll come back.
In this video, we are going to add a little functionality that you can add by yourself, actually,
because it's going to be super similar to what we have built so far.
And what I want you to do is I want you to create another aspect in this exercise activity, which should
be the screen or the view which displays the timer during the exercise.
So it's going to be very similar to what we already have with the timer for our wrist progress or our
risk timer.
But it's going to be for the exercise timer.
So there the timer should go for 30 seconds instead of 10 seconds.
And what you can do is you can go ahead and check out your.
XML file, so I'm going to show you real quick the layout file here, activity exercise.
So in here you can pretty much copy this whole linear layout with all of its contents up to here and
paste it in at the bottom here and give it an ID, then make some minor changes so that it looks like
the following.
So there we are, I pressed start and then the timer runs, so we've been that far already, but now
the next exercise is to get the next screen and you will see there we are.
So we have exercise name and then we have another time off, which goes down from 30 to one or actually
to zero.
So this is what you also can build.
And this is not a new screen.
This is just changing what you see on the screen.
All right.
This is not a new activity that we are displaying, but it's just going ahead and making the one linear
layout, which is this reste view invisible and copying this whole thing and then creating another linear
layout which you make visible.
All right.
And in order to do so, you can go ahead.
And I'm just going to show you real quick here in uncreated, just as an example, l l so linear layout,
rest, view, dot visibility.
So there is a property called visibility and you can set that to either view dot gone so it's not visible
or you dot visible.
All right.
So these are the two things that you need to use here.
But then of course it's not going to be inside of our uncreate, but it's going to be somewhere else.
So the general structure is we set up the rest of you when we get to this page.
So on create.
But then once the timer is up, which means in our own finish for our set rest progress bar and our
unfinished, we want to.
Make our rest of you invisible, but the exercise few visible and then the exercise, you will have
an own.
View so here and own function, which sets it up, we will have an on rest progress bar type of thing,
so it's going to be a exercise progress bar that needs to be set up and it's going to be an old timer.
So this is what you need to set up.
I wish you the best of luck to do that.
You should be able to do it, give it some time.
Don't worry, and don't push it too hard.
If it doesn't work after, let's say, half an hour or so, then you can, of course, check out the
video, but give it at least half an hour to to try and build that, because this will really help you
to make these concepts take.
All right, so I hope you you tried it.
So what we can do is we can just go ahead and copy this whole linear layout here.
And what I'm going to do is I'm just going to copy it from my prepared code here, so.
I can go through it real quickly, so I pasted just below our other linear layout, which is this.
All encompassing view, linear layout, OK?
Underneath I have this new linear layout, which I called exercise view.
It's matching the apparent when it comes to with and height and it should be below our toolbar.
Then we center it.
The orientation should be vertical visibility.
We set that at the beginning as gone by the tools visibility.
We set that to visible.
And this is something that you probably don't have in your code, and that's totally fine, but it's
really just there to make it visible in our tools, which means it's just there to be visible here in
our IDL in Android studio.
But it's not going to be visible in Android itself.
As you can see here, the Android visibility set to go on.
And if you want to know more about it, you can see here the stack overflow post here where it says
total invisibility is used to manipulate visibility in the idy.
It won't affect the view in real time.
It just used or it's just used for designing purposes in Android studio.
All right.
So that's the difference here.
We have those two different types.
OK, so this is our visibility gone and then we have our TextView, which is the text, the exercise
name.
And here we want to later have, of course, the name of the exercise.
And as you can see, we have a little smaller text size because exercise can be like longer.
And that creates a situation where they will go over and the borders will be a little too long.
But of course, you can also use 22 hesp here so that it is looking the same.
They are the same size, so to speak, because there was a little transition that wasn't that beautiful.
But it really depends on how you prefer it.
Right?
So that's the activity exercise.
Well then we have the frame layout, as we also had in the other one with the progress bar, which is
exactly the same progress bar except for its ID.
So here we are using progress bar exercise instead of rest progress bar or however we call this year
progress bar.
OK, we just called the progress bar before.
Maybe a better ID name would be Progress Bar here to make it clearer.
Then we have a linear layout which contains our text.
You OK, which then of course is the timer that we want to show.
So TV exercise timer is how I called it.
All right.
So that's the beginning of it.
That's just setting up the XML file.
But now we also need to set up the code in our file.
So here we need to have the same kind of stuff like here.
So we need timers.
But now it's not going to be REST's timers, but I'm going to call them exercise timer and I'm going
to call this exercise progress.
So exercise progress should be set to zero.
And now the next step would be to, of course, set the exercise progress bar up, which means that
it's going to be a very similar code to our set rest progress bar.
Now, you could, of course, argue that we could find a way to make it one function so that we set
them up with one function and then we have an if statement here, depending on what kind of progress
bar you want to set up, because they are pretty similar.
But I personally prefer in this case to really have an additional function which we can control directly.
And it's going to make it a lot easier also for discourse.
But of course, you can optimize this code a little bit, as I said, and here it really depends on
what you prefer.
Now, of course, we are not working with the progress bar as such, but we're working with the progress
bar exercise.
And here it's not that rest progress, but it's the exercise progress.
And by the way, something that I need to state here is if you copy code and paste it, then it's super
tricky because sometimes you forget to to change one variable name and suddenly the whole thing doesn't
work.
And then it's so difficult to find the book.
So this is something that I really don't recommend to always do.
All right.
So I only do that if you're super focused and really aware of what you copy and pasting there and what
you need to change.
Because if I forget to change this name, for example, then the countdown timer will always be this
rest time.
And for some reason, our other timer will never work.
All right.
So here, of course, does the exercise timer that I need to set the countdown duration should be thirty
milliseconds in the future.
And as I stated earlier, of course, you could create a variable here that will take care of this.
And yeah, here you can create a long variable.
So just to show you real quick, we could go ahead and create a private var and this is going to be.
Exercise timer duration, which is of type long, because it needs to be a long value, right, as our.
Countdown timer expects a long value, so you can always check it out, you can see long delays in future
or long count on interval.
So this is something that you need to take into consideration.
So now what you could, of course, do is go ahead and.
Go to the write function that's superimportant and here.
The variable that we created, which was.
Exercise timer, duration times 1000.
And then you can use this exercise time of duration here.
But then you need to make it to an integer, so you see a bunch of stuff that you need to take care
of because.
This is not an end, but it's expecting an end and so forth.
So that's why I hardcoded it.
So this is just show you in this video, but in the files that you will download, it will be hard coded.
All right.
Or that you can download the ones attached to this course or to this video.
All right.
So the year, of course, we're not talking about the rest progress, so we need to change that.
We're talking about exercise progress because we are in the set exercise, progress, bar function.
And I need to paste it in here as well, because it's super tricky if you miss one thing.
The whole code will not work as intended, and it's not even a bug, right, where it's not even an
error in the code is just a bug that we implemented then.
And that's super tough to figure out.
So progress for exercise, progress.
And then instead of the TV timer, this will be the TV exercise timer that we want to change the text
of.
And then, of course, the text that we want to show once we on finished year would be something here.
We will start the.
Next, the Taimur.
Something like that or green.
All right, so that's that, but then we also may not forget to set up the exercise view, so we need
another function, such as we created this rescue.
We need to do the same thing with the exercise you.
So set up exercise you and here it's not the rest timer, but it's the exercise timer that we need to.
We said and exercise progress.
We also need to reset.
And then here set.
Exercise, progress bar is what we need to call here.
Now, there is one more thing that we need to do.
We need to make stuff visible or invisible.
So, for example, the rest of you needs to be invisible.
So view that gun.
And then the El Al exercise view should be visible, so we set the visibility to view that visible.
And now, of course, we need to do the same thing where we need to also not forget to call our set
up exercise view somewhere.
So where would be a good spot?
Well, in the finish of our said rest progress bar, because here, once we finished the 10 second timer,
that's where we want to call this set up exercise views.
So we actually don't see this rest progress bar anymore, but we see the set up exercise for you.
And by that, I would say it's time to test this and see if what I've shown you here is actually true
and if that is going to.
Fix the issue and let's really quickly check exercise time, duration.
Well, while it's compiling, you could, of course, go ahead and also create a rest time or duration,
because then you don't have to go in here and attitudes here.
But you can directly at the time was here.
So if you later on decide, OK, it's not going to be 30 seconds, but it's going to be thirty five
seconds, then you can change it on one spot or at one spot and you don't have to change all the other
stuff afterwards.
All right.
But as the values will always be the same, right.
In this case, the rest should always be 10 seconds.
The exercise timer should always be 30 seconds.
That's why in this case, it's really fine to hardcoded, as we did with the rest progress bar.
All right.
So now we should be able to check it.
Let's start it.
Let's see if after ten seconds, our other view will appear.
And as you can see, we're not creating a new activity.
Right.
So this just bam, you see moving or making one thing disappear and making another thing appear.
All right, so I hope you manage to get this done by yourself or at least parts of it, because this
is going to be super helpful in general to really try stuff by yourself, because once you want to build
it for yourself with your own ideas, then it's just super helpful to have done stuff on your own.
And we can see here the finish is also called.
All right.
So see you in the next video.