1 00:00:00,380 --> 00:00:02,840 Our application is in pretty good shape. 2 00:00:02,840 --> 00:00:03,950 There is, however, 3 00:00:03,950 --> 00:00:08,670 one other thing we can do to help the performance of our RecyclerView. 4 00:00:08,670 --> 00:00:14,470 We can enable an optimization for cases when the size of the data set is static. 5 00:00:14,470 --> 00:00:19,262 In our case, the hourly forecast we're getting back from Dark Sky will always 6 00:00:19,262 --> 00:00:21,161 have the same number of items. 7 00:00:21,161 --> 00:00:23,813 We won't be adding or deleting any items. 8 00:00:23,813 --> 00:00:28,529 So, inside HourlyForecastActivity, we'll want to add this line. 9 00:00:28,529 --> 00:00:35,480 So, after we've done our binding, do binding.hourlyListItems, 10 00:00:35,480 --> 00:00:40,089 we'll use setHasFixedSize, set it to true. 11 00:00:41,610 --> 00:00:45,440 This allows the RecyclerView to perform several optimizations 12 00:00:45,440 --> 00:00:50,124 by knowing in advance that the size won't be affected by the adapter contents. 13 00:00:50,124 --> 00:00:54,040 While we're done with this app for now, I would like to stress that RecyclerView 14 00:00:54,040 --> 00:00:58,740 is very flexible and customizable, with a lot of available options. 15 00:00:58,740 --> 00:01:03,604 If we take a look at the documentation, we can find a list of public methods, 16 00:01:03,604 --> 00:01:06,250 and see a lot of them listed out. 17 00:01:06,250 --> 00:01:10,642 For example, if we want to add a dividing line between our list items, 18 00:01:10,642 --> 00:01:13,408 we can use this addItemDecoration method. 19 00:01:15,620 --> 00:01:16,811 So we go back to our app. 20 00:01:19,951 --> 00:01:20,627 Down here. 21 00:01:22,608 --> 00:01:23,914 We can do binding. 22 00:01:26,251 --> 00:01:31,380 HourlyListItems, we'll addItemDecoration. 23 00:01:31,380 --> 00:01:34,000 We can pass in, for example, a divider line. 24 00:01:35,140 --> 00:01:39,110 We'll do a new DividerItemDecoration. 25 00:01:39,110 --> 00:01:40,298 Context is this. 26 00:01:42,530 --> 00:01:44,481 And we'll do a DividerItemDecoration. 27 00:01:48,961 --> 00:01:50,920 And we want it to be vertical. 28 00:01:52,310 --> 00:01:53,539 Let's see what that looks like. 29 00:01:55,984 --> 00:01:57,046 Run our app again. 30 00:02:02,336 --> 00:02:07,260 Go over to the hourly forecast, and there's our divider lines. 31 00:02:07,260 --> 00:02:11,300 Perhaps not needed in the Stormy app, but it doesn't look too bad. 32 00:02:11,300 --> 00:02:15,000 There's definitely lots of ways to enhance an app with RecyclerView. 33 00:02:15,000 --> 00:02:19,077 I'd encourage you to see what you can do to make this app even better. 34 00:02:19,077 --> 00:02:21,967 There are some great animations available from, 35 00:02:21,967 --> 00:02:26,180 I'm not sure how to pronounce this exactly, wasabeef's GitHub site. 36 00:02:27,770 --> 00:02:30,542 You could try implementing some of these into your project. 37 00:02:34,886 --> 00:02:38,979 Or Treehouse offers a great course on animations and transitions, 38 00:02:38,979 --> 00:02:41,220 check the teacher's notes for links.