Bummer! This is just a preview. You need to be signed in with a Basic account to view the entire video.
Start a free Basic trial
to watch this video
We can now create some data model objects to hold the data we are getting from the Dark Sky service.
Related Links
- How to generate getters and setters without the "m" prefix (skip to the 5:33 mark)
-
0:00
Back here in Android Studio, let's create a new class in our project.
-
0:06
New Java class, we'll call it current weather.
-
0:08
And hit OK.
-
0:18
Cool, next, let's define our variables.
-
0:23
So we need a private string.
-
0:27
We'll need one for the location label.
-
0:31
We'll need a private string for our icon.
-
0:39
A private long for our time.
-
0:45
The temperature is in double value.
-
0:55
As is humidity.
-
1:02
And for precipitation we'll do a precipChance.
-
1:09
And we'll need a string for our summary.
-
1:14
Now we just need to type out all of our getters and setters.
-
1:17
Well, okay, let's not type them all out.
-
1:20
We can use Android Studio's auto generation feature to accomplish this.
-
1:25
If we go to Code, Generate, Getter and Setter,
-
1:29
we can select all the variables, and hit OK.
-
1:33
And there they are.
-
1:36
Very nice.
-
1:37
This is a great start for our data model.
-
1:40
We'll be making a few tweaks as we continue on with the project.
-
1:43
For now, though, let's jump back and look at this data format called JSON.
You need to sign up for Treehouse in order to download course files.
Sign up