Okay, good morning, good out. Yeah, almost afternoon.
When we know the date of the final. I have not checked the final exam schedule.
Is it a, is it out right now.
Check to see if the final exams, you know.
Okay, so it's so if it's out, it should be on there with the date of the final as I say just check.
I'll show you. I'll show you also yeah I find it
wrong one.
Okay, so here's the exam schedule.
Okay, April 14 at 2pm.
Good.
Two to four
fix that.
Good to ask look that up yet. So,
So let's, um,
let's go ahead and talk about where we are right now so yeah I owe you.
The next assignment so but see like some of you are having some questions about.
Alright, next the site will come out soon as I had hoped that by today but I'll give you guys enough time to work on it should be based on the stuff you've worked on, I'm going back to tutorial seven.
I get the sense that some of you are not so clear about what what this activity lifecycle I'm talking about. I've had a couple of people at say that. Okay.
Should I just add log messages to everything in the app.
It's like, No, that's not what the life cycle is the life cycle is specifically referring to.
Yeah, you know, this is the Android actually life cycle right here.
So if you look at it.
You know, there's this notion of, you know, the activities launched and then there's non create on start on resume. So, in what you want to doing is adding these sort of things to the other app, mostly but then you need to make sure you know, there's
also on create you already have and.
But it shouldn't require much fiddling.
It requires some filling to understand yes to understand to get these get these messages running it should be trivial copy paste it, but you need to run the app multiple times in different ways and switch between apps and to see when these different events
are triggered.
That's the thing that you need to understand.
So it's easy to remember, understanding, not just doing
unless there are specific questions about this tutorial, I'm happy to discuss. I want to do something a bit different.
What I wanted to do was, there's a tutorial for you can follow along but tutorial nine from last year has some, you know, has some code, which was, you know, there's a lot of code here a lot of different things going on.
Rather than just have the run this or or whatever, what I want to do is show you some of the ideas from this and build up a new program, step by step, so you all can see, you know, hopefully understand a few things so we see see new activities.
See, see shapes, few other things.
So any questions or can we just.
Okay, move on.
Okay, so let's, let's do this.
So first off, Android Studio. Let's make a new project.
So, if the activity.
Next, we'll call this.
Okay so test drive demo Caitlyn. Okay, looks good.
You over here, down a little bit. Okay, now we have our Android Studio, I get this error. I don't know why this this is a configuration thing with mine but I whenever I make a new project I'm using better Gk, then it's fine.
It's priceless. Yeah.
So new project. Okay, so.
So let's start building things up from scratch here so we've got a brand new brand new
thing if we run this right now.
Sorry,
people calling my cell phone that I don't know.
Okay, so there we go, it's ready. It's built, it's going, let's start the simulator and start building it have start simulators now this is just the basic hello world see it going
my computer isn't that slow was still this thing's
takes a takes a while on the first build.
So once this is built, we should see hello world.
And then we'll start making changes.
What
connection refused to try,
they're
no good reason for why that happened but it was glitchy and if you look here you'll see it says hello world.
Good job.
So, first off what I'm going to do is.
Yeah, I mean, I saw these things are racy like they're depending on their some time dependencies so
what's open up this so you can see the files of yours or Java one here's the main activity. Here's our resources.
Here's our layout.
Okay, so first thing I want to do is to put a circle on here.
I want to draw a circle.
Now, in, in Swift you I drawing a circle was pretty darn simple.
We literally just to, Here's the circle. Done.
There are ways to make a canvas and the canvas, looking to make an OpenGL canvas and that you do all these different shapes up it's like, I just want to shake.
Let's do that. So, seemed like the correct way to do things is by.
We're going to make something in XML to declare shape.
Now, I, I'm actually going to be you know copying this from from the other one to remember how to do all these things but.
So we're going to make a new draw herbal resource file.
And we're call this circle. Now we got a circle dot XML let's get rid of this.
Now we have our code here.
And so instead of saying so we don't want selector, this is actually not what we want.
We're going to make a
ship.
I was looking to see I could do this to the GUI and I could not figure out how to do it.
Okay.
Great.
Now it's getting a little annoyed. You like I don't know this name space.
So here is. So with XML, you have to get the.
Then,
and then I'm going to make all these trees.
Okay, so I will this is I actually do this right, was it just like any errors here.
Oh no, I didn't close off the
fine.
There we go.
If you did that right you notice it shows a circle here.
Yay.
So the question is so, so you can get just get random crashes.
So, the crash I had that that wasn't a random crash. The problem was is it was having problems connecting to know connecting to the simulator. So that was a connectivity issue.
That wasn't a random crash.
So it's important, it was having trouble connecting to it.
What linked I put after it so this is.
Let me show you what
can you window.
Okay.
I wanted.
So I had a, so this is actually where it specifies how to do this.
So this is the format of it.
She knows that it gives the schemas is think this is a valid URL.
Copy.
No, it's just an identifier is not actually a link.
It's, it's so what this is is this is specifying a.
So what's this excellent XML ns.
So.
xml i find kind of.
It's, it's a little lame, but so if you look here, what we've done is we said, No, so the whole notion of Android Colin shape, who defines that well it turns out, Android Colin shape is defined in the Android namespace.
And the Android namespace is defined in this schema.
Now this actually isn't a valid webpage.
It might have been at one point, but it's not a valid name page web page. It's just an identifier.
So you just gotta kind of stick it in there.
But once you stick it in there.
You get you know you can do things like this so we knew the oval. We can also say like rectangle.
And they'll make a rectangle
no space of the color here we can say, a cough.
That's yellow, so you can know this is all just regular, you know, colors, and we can do a.
So what was the other things we can do here. So we can also do a.
We're going to do a rectangle the oval didn't align and a ring, I haven't tried line in ring. Let's see what those do
line. Oh, just so it's not filled in.
Oh no.
I guess that's just an oval that's not filled in.
So,
oy still give me an error because it just hasn't updated.
So let's let's save and go here.
We're actually wait.
Oh, that's because of this.
Yeah.
I haven't closed off the XML.
That makes sense.
Okay, so.
So, say what so now we have the shape.
How do we show put it into our screen while we go to our layout
here.
What is it shows me
know.
I was curious that showed up in a menu my circle.
But I don't see it showing up here.
But what we can do is go to code.
So we have this text view here. So this is right now putting the center.
And so we can now to put in the circle.
Right.
So we put in there. We can do this I think
should yet image view. Yes.
So we can put image view in and put that over here.
And so when you know dragon image view, since we already have so there's all these different things we could put in there, but I've created the circle.
So I can select this and I can go. Okay, and now it's put the circle there in a very small size.
Missing constraints, yes, that makes sense, it's got missing constraints.
So let's look at its attributes. Let's make it a bit bigger.
wit to yd reset the layout width and height.
Here it is.
So we can instead make this
and make this.
there we've got 100 by hundred display pixel, so it's normally a dp, as opposed to pixels because some screens or higher resolution than others. So, but this is a standard measurement for Android.
So we've now specified this be hundred by 100.
What we can also right what.
There we go. 100 by 100.
But it doesn't have to be equal, you could make this 200
It would be no no so but if you want to circle we make it equal otherwise we get some shape of an oval.
So if. So it turns out that. So, so the link was at a website and do not work up.
So the question is is when you go to the XML namespace. So if you go here, these XML name spaces show up all over the place. You'll notice these things like okay here here's the same namespace here.
This is, this was kind of a stupid thing because this isn't a valid URL anymore.
It's really just a unique identifier that the Android thing so it has enough, it doesn't actually can any, in principle, an XML purser could go out to the internet and find this, but in the context of Android, it says, Oh, I know that XML namespace.
And so it just uses it.
I think it used to be a valid thing.
But know that I'm kind of surprised they didn't at least keep it up as a nine get this to go anywhere.
No, yeah.
It doesn't work I tried another browser window.
But, but what if it does, though, um, what if it does resolve to something
quick mess with your XML, and what it means is underneath there is some XML document defining that namespace.
So in principle if you loaded from somewhere else I could do things but really, even though as http colon slash slash in it. It's really just an identifier.
We've got a circle here.
Let's now let's change the layouts.
We're going to.
So let's just make the.
Okay.
There. Okay, so that will be 56 pixels below that.
That seems fine.
Let's just try launching this and see if that works.
Oh, what do you upset about
100 and currently with.
Oh, what did I do here.
Let's look at the code. This is why the code is without with this 100
mess up here.
Oh,
units.
Now let's see if it's fine
now.
So, Again, it's not succeed. right.
There we go.
Okay, yeah. So we've got the circle as expected here hello world they're
good to go.
Now, okay, I have a circle here.
What if I want to do something with it. Well first of all, this is a really stupid name.
Call it circle,
red
color red circle. So, so we have a red circle.
What if I want to, you know, do some stuff with moving the circle.
How would I, how could I mess with this from the program side. Why now go over to main activity
here.
And let's try this again.
So now we're going to try doing something with the circle so what's the first thing I need to do with the circle. I need to
get its info.
So first thing you want to do is we're going to say.
So it's a view like any of you.
But notice it says something here, it's not.
We got what's that red there mean unresolved enter import.
So here, now imported that.
So that's good. And now, In here we want to do something with it.
So we've got a rough we have, we have to actually assign it to evaluate. So, After we've set this here will say, red circle.
This is very much like web programming red circle.
So now, red circle in our code is referring to the red circle in the layout.
We have something specific, we want to do with it.
So, how about I change its location.
So now let me do your document. Exactly, yes.
So let's make it.
Okay, so we can say red circle dot
x is equal to.
Let's make it 20.
y equal to zero. So I'm just I'm just setting up some stupid values.
But let's check to make sure that did what I expected it to do.
Really.
How bright.
This is.
You have to specify the type will say it's a float or zero know what to say it's a float.
That's annoying.
Yeah.
Oh, right.
Forgot to do
change that but I so it did not move.
Right, so
I have to actually get this to.
Oh, you have to invalidate the view.
No So what happened is I changed the geometry of the position of the circle, but it didn't refresh the screen. This is the same layout as where it was mentioned so I, there was a thing you have to do is like.
Okay, let's try
to see didn't move the same official. Okay, well, we'll just we'll try.
Oh, it did move.
Oh, it's moving relative to its original position.
Yeah. Yep. it moved. I was thinking there's a
there's a method I'm looking for which I was thinking of was as the Android view invalidate so I shouldn't be able to do.
Okay, nevermind. But, so the circle moved.
What's the saying though this is saying that its position is when you set x here, it's.
Let's go over here.
so irritated by is the coordinate values.
You
You really want the absolute value
position. Okay, so we the location of a view by invoking to get left and get top from the left of the rectangle representing the view, right.
So,
okay.
So, if we do, let's see if we can do that if we get, get, so I'm saying is get right and get left, we should be able to use that to find where this thing is positioned well let's let's get it to log it.
So here.
The.
work.
Oh, right, fine.
Important
do lots of imports.
In.
Oh yeah.
Left.
Get left. Yeah, we should do get laughed.
I agree.
It's not will tell us our, our value there. Now let's either convert this to a string
to
work.
concatenation that way.
know the archives.
Know fine find me call the artist so public functional.
Oh, I think, Oh yeah, They want me to do.
It wants me to format streams.
Okay.
No, that's not right.
Oh, the dollar sign. Thank you.
I use too much syntax I'm trying to remember which is which.
Right, so, dollar actually will say, Well then why do let, let
go now.
Well.
cool.
will be happy with that.
1713 okay so.
Oh, right.
Now looking at the code here
doing this wrong log has to fit the two avenues so.
equals.
That's right, I forgot.
Now this is the message.
That's why it was saying,
Okay What did it look at.
So circle left is zero.
That's interesting.
This is circle left to zero.
And.
does that work.
00.
Yeah. Yep. It steering the.
Is it supposed to be right.
The view is still at 000 but it's not telling the view. Yeah.
I want to do some stuff on Android geometry I'll do that later but well.
I had a really Genki way of doing things. Oh, right.
That's what I had.
Why is that not right.
Oh,
no, that's not that doesn't exist.
Isn't this before you change the x file yeah this is.
So what I'm going to show you, neck, let me just, I'm going to show you something else will fit will show you this in a little bit, then I want to the geometry transformations and Android.
I don't think I quite have We'll figure that out before next class.
Because last, last time I did this I use a really Genki way of doing things.
And I will show you how that works. But I'm hoping to have that fixed.
Let's get rid of this.
So, all this stuff here.
comments out,
third option just to comment.
should be the obvious thing to put in there.
So, one of the reasons. So, one of the reasons why I'm doing this because normally I can have all this worked out beforehand and show you exactly this is to show you that
this is programming.
It's kind of annoying at times, trying to remember what do I do here What's this thing they're just.
You're always playing with stuff and trying things out, you've got to do little experiments to try to figure out what's going on there and do things to say, what's actually happening.
And so, I know this x and y is in a is relative clearly to where the view is input and it starts off at zero. So
it's googling the chat.
What is that soul searching that. So, using Google is important, because really that's just a way of looking up documentation, but you don't want to just get code fragments and just stick it in.
You have to go like, what is happening here.
So, for example, so so now let's see I'll show you now how these touch actions work.
So what we can do now is make a.
I'm going to put in this little.
So this is stuff up.
Okay, so this is.
And then we're going to override
you.
Okay, and then.
So we've done this year.
Yes, I've been pointing motion event.
Why is the same here.
Now, I want this year.
So, since I've created this on touch listener.
This is something you know you look up to find the on touch listening you'll find that but note that you're going to have this, this thing overriding this, you know, this is basically an on touch listener just an object.
We're overriding the on touch method of that, but we want to associate that with the circle.
So we actually want to put this here and say.
So what I wanted to hear. Oh, right.
Right.
So we now have connected saying we've added on touch listening here this object. It's all happy and we've got this year so the question is, is what we want to do here in this in this thing so you want to say.
For first.
No.
So, what we're doing here with this is making this.
See this is these are both have a question mark. After them so they mean that they could be no, or they could be a valid object. So, in Caitlyn rather than doing it, if let, what we do is we just do an if, check if there are no, make sure things are taken
care of. And so then after that, we can just use those values, and it will be fine, it will say okay yeah you've already checked to see whether they're know, so you're good.
So,
So, and then
this is what you told me just show you what this how this works.
expression.
This will show us the.
Okay, there we go. now we've returned true we've returned false. So it's happy with, with our thing, and we're now logging things. So let's see what happens when we do this.
Because fine.
No.
Build
Let's see.
Well, right now we're not right.
Are we running.
Okay, good.
That's what I want to do.
Oh, there we go.
So,
that's not doing anything but if I click in here and I move these.
Getting.
Why is it keeps disconnecting.
Give me my events.
So you see all these coordinates here we get.
Know that semi colon is not needed
that cycle is definitely not needed that is habit.
So we're getting a bunch of coordinates here. So what we could do is just
please use this action here so that's the dry coordinates.
So have these coordinates.
While we're moving it.
And we're going to say circle dot x equals.
These a little simpler here and then we can put this
xy, and then we can circle x equals x, not so cool.
So cool.
So let's see what happens now.
this.
So we get a drag it as well I hope I'm holding down the mouse.
As well I hope I'm holding down the mouse. So here's the thing, like, it will, I can drag it but look I'm off on where the circle is, I've got, you know, see what the mouse pointer is, I've got this offset.
So, last year when I did this, I just manually.
I did it really an agenda way I did.
F.
o. That's what I did. Let's see does that actually it was that correct adjustments.
It's better not quite, I need to be a little lower,
but just look at that, that's just, yeah. That's just wrong.
I got that working, I'm going to figure out how to get it, get the right coordinate transfer forums and I'm going to show you that for next time.
We're almost out of time here. I think I've been showing you enough stuff. The last thing I
can you remove the constraints when you drive.
What do you mean by remove the constraints.
What constraint Are you talking about.
Steve I'm not quite sure what you're talking about.
Oh no no so what's happening right now is I'm setting the position of these things to be the raw coordinates here, and I haven't done the proper transform from the raw coordinates to the, the ones for the view.
So I really need to do it relative to where the view where the event happened.
I think if I just do.
I just do this.
What does that do for a call that doesn't work right.
This is what happens.
It's like the kind of follows.
But it doesn't really follow.
Yeah.
That's why I switch the rock coordinates, but then I have to transform the rock coordinates, like, yeah.
Anyway,
if anyone figures out how I this is something I've been meaning to figure out if it wants to figure this out and look online let me know, I'd be very curious to see, otherwise I should have something for you by next week.
I'm going to stop here. I'm happy to talk to help check off tutorials and answer questions, and the assignment three should come out soon.
Alright. Have a good day and otherwise you all can head off. If you don't want to do those things.
I don't know if any of you have most of you probably are not affected by March Break. I think March Break for those who are in, you know, elementary High School and thing is, is this next week at least it is here in this in the US.