1 00:00:05,300 --> 00:00:06,810 Alright, so I've re synced the project, 2 00:00:06,810 --> 00:00:09,260 and rebuilt it just to make sure everything's okay. 3 00:00:09,260 --> 00:00:10,360 And you can see that I'm now running 4 00:00:10,360 --> 00:00:12,360 the latest version of Kotlin. 5 00:00:12,360 --> 00:00:14,070 I'm no longer getting any warnings here 6 00:00:14,070 --> 00:00:15,700 that there's a new version so I'm actually, 7 00:00:15,700 --> 00:00:17,230 I've got the latest version. 8 00:00:17,230 --> 00:00:21,053 In the case of this update, the new update of Kotlin, 9 00:00:21,053 --> 00:00:23,630 I've updated the link checks amongst other things 10 00:00:23,630 --> 00:00:27,230 and certainly well worth updating the versions of Kotlin. 11 00:00:27,230 --> 00:00:29,140 And quite well as they come out with the updates. 12 00:00:29,140 --> 00:00:31,500 Alright so this videos gonna be a quick one. 13 00:00:31,500 --> 00:00:33,720 We've gotta couple of small corrections to make. 14 00:00:33,720 --> 00:00:34,980 First one, is I'm going to open the code 15 00:00:34,980 --> 00:00:39,393 and we're going to open the add edit fragment class. 16 00:00:44,770 --> 00:00:46,800 Okay, a bit more space there 17 00:00:46,800 --> 00:00:48,410 and there's a small correction. 18 00:00:48,410 --> 00:00:50,070 And the correction's actually in the comment, 19 00:00:50,070 --> 00:00:51,990 which has confused a few people. 20 00:00:51,990 --> 00:00:53,850 And it's because I made a typo. 21 00:00:53,850 --> 00:00:57,150 So down here on line 59, that should have actually 22 00:00:57,150 --> 00:00:59,936 read "We're not editing an existing one." 23 00:00:59,936 --> 00:01:02,060 and I put and editing an existing one 24 00:01:02,060 --> 00:01:03,823 So that should be and not. 25 00:01:04,660 --> 00:01:06,680 Put it in uppercase to emphasise it. 26 00:01:06,680 --> 00:01:08,420 Editing another thing, so the complete line 27 00:01:08,420 --> 00:01:10,750 no task, so we must be adding a new task 28 00:01:10,750 --> 00:01:13,170 and not editing an existing one. 29 00:01:13,170 --> 00:01:14,910 Alright the second correction is a result 30 00:01:14,910 --> 00:01:16,940 of switching between Java and Kotlin. 31 00:01:16,940 --> 00:01:18,951 What I've done is I've used stream concatenation 32 00:01:18,951 --> 00:01:21,080 in the un-attach function. 33 00:01:21,080 --> 00:01:23,620 So if we go down and check that out. 34 00:01:23,620 --> 00:01:25,520 It's down here towards the end on line 35 00:01:27,312 --> 00:01:28,547 there it is, on line 129. 36 00:01:28,547 --> 00:01:31,730 And you can see there's a warning there on line 129. 37 00:01:31,730 --> 00:01:34,040 Convert concatenation to template. 38 00:01:34,040 --> 00:01:37,050 And into our studio, we'll actually offer to fix that. 39 00:01:37,050 --> 00:01:39,690 So if you come over here, click in there, 40 00:01:39,690 --> 00:01:41,600 move over to the locked light bulb, 41 00:01:41,600 --> 00:01:44,410 convert concatenation to template option to change that 42 00:01:44,410 --> 00:01:47,650 I click on that and its measured in now a more Kotlin 43 00:01:47,650 --> 00:01:50,390 style syntext with a dollar context. 44 00:01:50,390 --> 00:01:52,660 Instead of using stream concatenation. 45 00:01:52,660 --> 00:01:54,870 Alright, so that's something we need to make 46 00:01:54,870 --> 00:01:57,590 two changes we need to make to edited fragment. 47 00:01:57,590 --> 00:02:00,148 If you open up app provider, the Kotlin class, 48 00:02:00,148 --> 00:02:03,550 we'll see that there's quite a few warnings showing there. 49 00:02:03,550 --> 00:02:06,150 Now the first couple, we look at those, 50 00:02:06,150 --> 00:02:08,160 they're relating to the fact that we're not using 51 00:02:08,160 --> 00:02:09,479 those constants yet. 52 00:02:09,479 --> 00:02:12,320 And specifically that's the code on line 29 and 30. 53 00:02:12,320 --> 00:02:14,120 You can see towards the bottom of the screen. 54 00:02:14,120 --> 00:02:16,080 I'm going to ignore those warnings. 55 00:02:16,080 --> 00:02:17,370 That's because we're gonna be using those 56 00:02:17,370 --> 00:02:20,560 two constants soon in future videos. 57 00:02:20,560 --> 00:02:21,550 But, if we scroll down and look 58 00:02:21,550 --> 00:02:23,870 at some of these other warnings, 59 00:02:23,870 --> 00:02:25,990 first ones actually line 43 I think 60 00:02:25,990 --> 00:02:27,860 from memory, you can see over here that's actually 61 00:02:27,860 --> 00:02:30,550 introducing a warning, redundant semicolon. 62 00:02:30,550 --> 00:02:32,400 So I'm going to actually remove that. 63 00:02:33,380 --> 00:02:36,100 There's also another one on line 48. 64 00:02:36,100 --> 00:02:38,290 That just removes a few of the warnings. 65 00:02:38,290 --> 00:02:40,109 Now, all the remaining warnings should be because 66 00:02:40,109 --> 00:02:43,540 the get context function should return now. 67 00:02:43,540 --> 00:02:45,190 We just look up one of those now. 68 00:02:47,260 --> 00:02:48,840 Now, we're not calling the function, 69 00:02:48,840 --> 00:02:52,550 we're using Kotlin's ability to access it as a property. 70 00:02:52,550 --> 00:02:54,610 But the net results the same. 71 00:02:54,610 --> 00:02:56,838 The light bulb can help in this scenario. 72 00:02:56,838 --> 00:02:58,830 What we want is this first option. 73 00:02:58,830 --> 00:03:00,600 We go over to bring up the light bulb, 74 00:03:00,600 --> 00:03:02,815 I'll go down a little bit so you can see. 75 00:03:02,815 --> 00:03:04,668 The actual code. 76 00:03:04,668 --> 00:03:07,147 We'll go into that warning, first one. 77 00:03:07,147 --> 00:03:11,170 So I click in there and check the light bulb. 78 00:03:11,170 --> 00:03:14,120 This first option here, inspect nullability mismatched 79 00:03:14,120 --> 00:03:15,780 based on Java annotations. 80 00:03:15,780 --> 00:03:18,680 I'm gonna check that, or I'm going to click that rather. 81 00:03:18,680 --> 00:03:21,430 Then the one we actually want is to select this option here. 82 00:03:21,430 --> 00:03:23,980 The first one, suppress that the nullability 83 00:03:23,980 --> 00:03:27,380 mismatch based on Java annotations for the entire class. 84 00:03:27,380 --> 00:03:28,600 So for class app provider. 85 00:03:28,600 --> 00:03:30,700 So I click on that, you should 86 00:03:30,700 --> 00:03:32,580 see all those warnings disappear. 87 00:03:32,580 --> 00:03:34,290 Which they have, and if we go back up to the top 88 00:03:34,290 --> 00:03:36,213 of the class, we'll see that it's just added 89 00:03:36,213 --> 00:03:39,330 an annotation to the top of the class. 90 00:03:39,330 --> 00:03:41,252 It's added that line 34. 91 00:03:41,252 --> 00:03:43,240 As you can see there now. 92 00:03:43,240 --> 00:03:44,879 Now is it safe to do what I've just done? 93 00:03:44,879 --> 00:03:47,190 Well, yes it is or I wouldn't have done it. 94 00:03:47,190 --> 00:03:49,500 Now if we actually control click on the context. 95 00:03:49,500 --> 00:03:51,470 Or command click, if your on a Mac. 96 00:03:51,470 --> 00:03:53,283 And I'll go down to context again. 97 00:03:55,340 --> 00:03:58,670 And then to here and I'll do a control click there. 98 00:03:58,670 --> 00:04:00,160 And that's gone into the Java source code 99 00:04:00,160 --> 00:04:01,620 for content provider. 100 00:04:01,620 --> 00:04:04,417 Now the doc stream for the get context method there 101 00:04:04,417 --> 00:04:07,810 is actually telling us, or explaining that it's only 102 00:04:07,810 --> 00:04:11,070 available once Oncreate has been called. 103 00:04:11,070 --> 00:04:12,790 You can see that on line 712. 104 00:04:12,790 --> 00:04:16,440 So if we try to get the context before then, we'll get null. 105 00:04:16,440 --> 00:04:18,790 But in our scenario, with our code, we're not doing that. 106 00:04:18,790 --> 00:04:21,130 Because all the places in our provider where we're 107 00:04:21,130 --> 00:04:24,860 getting our context, are definitely after Oncreate. 108 00:04:24,860 --> 00:04:27,300 So therefore it's definitely safe to suppress the warning. 109 00:04:27,300 --> 00:04:28,133 As you saw me do. 110 00:04:28,133 --> 00:04:30,620 Alright, so I'm gonna close down that now. 111 00:04:30,620 --> 00:04:32,290 So, that's a bit of tidying up 112 00:04:32,290 --> 00:04:33,930 and checking your Kotlin version 113 00:04:33,930 --> 00:04:36,560 is something you want to do whenever Andriod Studio 114 00:04:36,560 --> 00:04:38,640 updates that Kotlin plag-ing because you'll find those 115 00:04:38,640 --> 00:04:41,590 new warnings that perhaps weren't there in older versions. 116 00:04:41,590 --> 00:04:43,210 Alright, so let's end the video here. 117 00:04:43,210 --> 00:04:45,776 And in the net one, we'll continue on with the adapter 118 00:04:45,776 --> 00:04:47,840 for our recycler view. 119 00:04:47,840 --> 00:04:49,140 See you in the next video.