02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Making our application redraw each time screen changes

Our ruler looks great but only problem is that as soon as the user rotates there device our application doesn't look all that no more. In this video we will fix that problem by enabling our application to redraw itself each time the orientation changes.It's time for us to test out our application in a mobile Android device to discover we have a bug. In the next video we will address the bug.

Video Transcript

00:00Now last but not least we could also decide if we wanted our first position to actually have anything because we might want to
00:06put those smaller dots around there instead or we could start off with maybe a little square inside of here just for the
00:13Position if that's what we wanted to do now to do that is also incredibly easy
00:17What we could do is just before we start all these inches and all these definitions
00:21We could basically draw a complete square. So to do that, I'm going to go to my ruler
00:27dot graphics dot
00:30draw
00:31Square we're going to look for that square draw a rectangle. We're going to start at 0 0 how many what is the width is going
00:38to be a full step size
00:40full step size for the height as well and
00:44We've just created a rectangle all that's left for me to do is in my ruler dot graphics dot
00:50Whether let me show it to you before even so if I just click on draw a rectangle and we run it up
00:55We'll see that automatically it's going to draw out our rectangle
00:59We don't really need to add much more than so we have this nice rectangle
01:02But we probably don't want to run the line that we created earlier twice
01:06so the way we could avoid that is literally by skipping the first step by making sure that our eye starts at one instead of
01:12At zero because one our zero position was created in line 28
01:16So I could do the same here also for our second for making sure that it's only being called one
01:21I'm not gonna run it again because it's gonna look exactly the same
01:23But we're being more efficient because we already created it in line 28 where we created our square
01:29now one more thing that I wanted to talk about is
01:32basically our capability of actually creating some level of
01:39Basically
01:41Basically, oh, yeah, what am I talking about? So let me show it to you before I talk further
01:44So although it's working for us right now and for now we're fine with the square
01:47We might change it later
01:48Once we've figured out that this doesn't really help the user because it doesn't it doesn't give an actual
01:52Measurement to anyone. It's nice to see but probably what we want to do in this area is maybe keep it empty or
01:59Better off probably put inside the smaller sizes and there to make it easier for users
02:03To define and once we know with those smaller sizes and maybe put there a little square in those smaller sizes
02:08Now I wanted to talk about one more thing is now that when we click on that resize
02:12Although our logo is going to reposition the way it's supposed to position if I read a line it will see that our our
02:20our
02:23Element although it looks fine is not actually
02:26Re-rendering each time and the reason it's not re-rendering literally because our refresh ruler happens only once
02:32We're not actually calling it out again once we refresh our ruler
02:36So what I want to do next is I want to basically instead of only calling it here to call our refresh ruler inside of our on
02:43Change now, don't forget that right now. We're working on a very specific definition. We're working on
02:49480 by 800 but the reality of it is is that our device might be much larger than that
02:55To make sure that it actually will always work on every single device and even before that I want to show you why we're doing this
03:01Okay, so right now it's only going to refresh once it actually changes, but when we first run our application
03:06There'll be no ruler
03:08Beyond that if I'm just gonna run the debugger and we're gonna run it right on to my device here for a second
03:13And I'll get my device ready. So once it loads up
03:16We're gonna see that we're gonna have a problem
03:18The first problem is is it's not going to be our logo initially is not going to be in the center
03:22And it's probably not gonna draw out the way we want it to draw out. So now that we're already connected
03:27I'm gonna just grab it and show you how it our application looks by default right now and by default
03:33It's not really showing much
03:34But once I rotate our application, it's now gonna start drawing those lines that we were expecting it to draw
03:40But we're not seeing it in a consistent way
03:44So to fix that problem and to make it actually visible in every single in every single
03:50Format, what we want to do is we want to make sure that we have a couple of changes
03:53one is also notice that when we're looking at the device and we're doing a little bit of debugging now that we see a
03:59device that's in a different size
04:00We see that we're missing one of the inch lines because we actually used it in the beginning instead of using it in the end
04:07So we want to offset that problem and fix that so we're going to look into our debugger to do that and at the same
04:12Time we want to make sure that as soon as the application loads the logo will be in the right position
04:17Which is the center and we're going to take care of that right away in the next video

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!