Enhancing Looks & Performance2:41 with Ken Alger
With the functionality of our app complete, let's take a quick look at some additional features we can add.
Our application is in pretty good shape. 0:00 There is, however, 0:02 one other thing we can do to help the performance of our RecyclerView. 0:03 We can enable an optimization for cases when the size of the data set is static. 0:08 In our case, the hourly forecast we're getting back from Dark Sky will always 0:14 have the same number of items. 0:19 We won't be adding or deleting any items. 0:21 So, inside HourlyForecastActivity, we'll want to add this line. 0:23 So, after we've done our binding, do binding.hourlyListItems, 0:28 we'll use setHasFixedSize, set it to true. 0:35 This allows the RecyclerView to perform several optimizations 0:41 by knowing in advance that the size won't be affected by the adapter contents. 0:45 While we're done with this app for now, I would like to stress that RecyclerView 0:50 is very flexible and customizable, with a lot of available options. 0:54 If we take a look at the documentation, we can find a list of public methods, 0:58 and see a lot of them listed out. 1:03 For example, if we want to add a dividing line between our list items, 1:06 we can use this addItemDecoration method. 1:10 So we go back to our app. 1:15 Down here. 1:19 We can do binding. 1:22 HourlyListItems, we'll andItemDecoration. 1:26 We can pass in, for example, a divider line. 1:31 We'll do a new DividerItemDecoration. 1:35 Context is this. 1:39 And we'll do a DividerItemDecoration. 1:42 And we want it to be vertical. 1:48 Let's see what that looks like. 1:52 Run our app again. 1:55 Go over to the hourly forecast, and there's our divider lines. 2:02 Perhaps not needed in the Stormy app, but it doesn't look too bad. 2:07 There's definitely lots of ways to enhance an app with RecyclerView. 2:11 I'd encourage you to see what you can do to make this app even better. 2:15 There are some great animations available from, 2:19 I'm not sure how to pronounce this exactly, wasabeef's GitHub site. 2:21 You could try implementing some of these into your project. 2:27 Or Treehouse offers a great course on animations and transitions, 2:34 check the teacher's notes for links 2:38
You need to sign up for Treehouse in order to download course files.Sign up