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