1 00:00:00,270 --> 00:00:03,620 Our app is working with our manual, static data. 2 00:00:03,620 --> 00:00:06,900 Let's make the necessary changes to get our JSON data coming through. 3 00:00:07,910 --> 00:00:10,830 We'll be touching a lot of different files in this video but 4 00:00:10,830 --> 00:00:12,210 nothing too extensive in each one. 5 00:00:13,220 --> 00:00:17,710 In fact, the biggest change in terms of number of lines of code 6 00:00:17,710 --> 00:00:19,150 we can do right now. 7 00:00:19,150 --> 00:00:23,860 We can delete our entire getHourData method in HourlyForecastActivity. 8 00:00:25,470 --> 00:00:25,970 Come down here. 9 00:00:28,802 --> 00:00:31,760 Can delete that, bye-bye. 10 00:00:31,760 --> 00:00:34,240 You were great and very helpful. 11 00:00:34,240 --> 00:00:39,400 Our first step in getting our JSON data is to make the hour class implement the Java 12 00:00:39,400 --> 00:00:41,680 serializable interface. 13 00:00:41,680 --> 00:00:45,730 Making an object serializable allows for the object to be safe for later. 14 00:00:46,870 --> 00:00:51,190 I've put some links for more information about the serializable interface and 15 00:00:51,190 --> 00:00:54,950 Java serialization in general in the teacher's notes. 16 00:00:54,950 --> 00:01:02,570 So in the Hour class, Come up here and 17 00:01:02,570 --> 00:01:09,776 type implements Serializable. 18 00:01:11,048 --> 00:01:17,178 Next, in MainActivity, gonna open that up, we go down to the hourlyOnClick method. 19 00:01:23,369 --> 00:01:25,270 Down here at the bottom, we need to add an extra to our intent. 20 00:01:25,270 --> 00:01:27,120 We need a list of hours. 21 00:01:27,120 --> 00:01:30,811 We can get that from the get HourlyForcastActivity method we wrote over 22 00:01:30,811 --> 00:01:31,557 in Forecast. 23 00:01:35,878 --> 00:01:40,543 So we're gonna do a List, 24 00:01:40,543 --> 00:01:44,124 quick fix for our imports. 25 00:01:44,124 --> 00:01:52,680 Call it hours, Arrays.asList(forecast.getHourlyForecast. 26 00:01:54,920 --> 00:01:57,423 And then we put that information into our intent. 27 00:02:01,119 --> 00:02:08,911 So intent.putExtra, We'll call it HourlyList. 28 00:02:14,355 --> 00:02:17,296 And we want a Serializable of hours. 29 00:02:20,212 --> 00:02:24,347 Now we can turn our attention back to HourlyForecastActivity and get and 30 00:02:24,347 --> 00:02:25,374 pass in our data. 31 00:02:25,374 --> 00:02:27,680 Go back to HourlyForecastActivity. 32 00:02:29,278 --> 00:02:30,789 Here inside onCreate, 33 00:02:30,789 --> 00:02:35,709 we need to get the data from the intent that we added over in the MainActivity. 34 00:02:40,471 --> 00:02:46,271 So Intent, Quick fix our imports, call it intent. 35 00:02:49,492 --> 00:02:57,407 Get the intent, List of hours, we call it hoursList, 36 00:03:00,815 --> 00:03:06,773 Dual cast, And get our data. 37 00:03:10,225 --> 00:03:11,363 Get the serializeable data. 38 00:03:14,215 --> 00:03:16,790 Get SerializeableExtra. 39 00:03:16,790 --> 00:03:19,086 We called it HourlyList. 40 00:03:25,038 --> 00:03:26,380 And let's drop this down under new line. 41 00:03:27,660 --> 00:03:30,290 Here, where we've defined our adapter, and 42 00:03:30,290 --> 00:03:33,530 we're calling our deleted getHourData method. 43 00:03:33,530 --> 00:03:36,179 We can now replace that with our hoursList. 44 00:03:39,594 --> 00:03:40,720 That was a lot of steps. 45 00:03:40,720 --> 00:03:43,540 Let's walk through all that again. 46 00:03:43,540 --> 00:03:47,430 We updated the hour class to implement Serializable, allowing for 47 00:03:47,430 --> 00:03:51,750 the data to be saved in memory and passed to the HourlyForecastActivity. 48 00:03:51,750 --> 00:03:53,980 Next, we headed over to MainActivity. 49 00:03:53,980 --> 00:03:58,550 Here, we added our hourly data to our intent, with the putExtra method, 50 00:03:58,550 --> 00:04:02,080 which allows our HourlyForecastActivity to gain access to that. 51 00:04:03,150 --> 00:04:05,065 Then we headed to HourlyForecastActivity. 52 00:04:06,510 --> 00:04:11,130 Over here inside onCreate, we were able to get the serialized data 53 00:04:11,130 --> 00:04:15,450 from the intent with the getSeralizableExtra method. 54 00:04:15,450 --> 00:04:19,760 Finally, we updated the adapter to use our dynamic data source. 55 00:04:19,760 --> 00:04:23,225 All right, let's run our app again and see it all working. 56 00:04:28,879 --> 00:04:31,356 So there is our app we click on hourly forecast. 57 00:04:34,088 --> 00:04:39,329 There's our data in a recycler view and scrolling around. 58 00:04:39,329 --> 00:04:42,708 Awesome, well done, we've taken our stormy app and 59 00:04:42,708 --> 00:04:47,020 added the ability to see hourly data in our recycler view. 60 00:04:47,020 --> 00:04:50,300 You should be super proud of the work you've put in so far. 61 00:04:50,300 --> 00:04:53,150 There's one other quick thing we should do in our app to make it work 62 00:04:53,150 --> 00:04:54,450 a little better. 63 00:04:54,450 --> 00:04:56,160 Let's take a look in the next video.