1 00:00:00,730 --> 00:00:01,480 Welcome back. 2 00:00:01,660 --> 00:00:08,480 So now that we have set up our specific content, piece or card should look like for our categories. 3 00:00:08,500 --> 00:00:10,750 Let's go ahead and actually. 4 00:00:11,850 --> 00:00:14,850 Set it up so that it loads data and displays it right here. 5 00:00:16,680 --> 00:00:22,210 Therefore, let's create a method that gives us the. 6 00:00:23,350 --> 00:00:27,880 Items by category, because here so far, we have gotten them by country, right? 7 00:00:28,360 --> 00:00:30,410 But now we're going to search them by category. 8 00:00:30,430 --> 00:00:36,760 We could, of course, say we also want to get the country, but yeah, let's just go ahead and do it 9 00:00:36,760 --> 00:00:38,260 like, so all right. 10 00:00:38,260 --> 00:00:45,310 So we're going to use a new function, get articles by category 11 00:00:48,610 --> 00:00:51,640 excel or by categories, whatever should be fine. 12 00:00:51,970 --> 00:00:56,740 And here I'm going to use the query keyword. 13 00:00:56,870 --> 00:00:59,290 I'm going to pass in the category. 14 00:01:01,240 --> 00:01:07,990 So and then I'm going to get to category which will be of type string. 15 00:01:08,770 --> 00:01:17,420 The second part of the query will be at query, which will be the API key. 16 00:01:17,450 --> 00:01:18,730 So it's going to be. 17 00:01:19,980 --> 00:01:22,050 This will be the same thing as we have done here. 18 00:01:22,680 --> 00:01:28,620 So the only thing that we're changing is basically going to be the key word, the query, key words 19 00:01:28,620 --> 00:01:29,490 that we're passing. 20 00:01:29,790 --> 00:01:32,970 So we're now passing that country, but category. 21 00:01:34,110 --> 00:01:39,510 So now let's set up our news manager, that's the news manager can work with it because we had this 22 00:01:39,510 --> 00:01:48,840 news response before we had the selected category, but now we also need to get the category by while 23 00:01:48,840 --> 00:01:51,990 the article by category so private vol. 24 00:01:52,560 --> 00:01:59,490 Basically the same thing that we did here and let me just set it up real quick underscore get article 25 00:02:01,290 --> 00:02:07,110 by category, which will still be a mutable state of top news response. 26 00:02:07,620 --> 00:02:17,400 And then this will be get article by category, which will be a mutable state so we can change. 27 00:02:17,400 --> 00:02:21,270 That state will not just be a normal state, which would be immutable. 28 00:02:21,270 --> 00:02:25,080 We can change it off top news response and it will be a. 29 00:02:27,860 --> 00:02:35,120 Remember, Composable gets her of the get article by category, so this is just worth creating a satire 30 00:02:35,120 --> 00:02:41,450 and get her right so we can get the data from other classes, but we can only set them inside of the 31 00:02:41,450 --> 00:02:42,530 news manager itself. 32 00:02:45,350 --> 00:02:50,300 And now we can go ahead and create a method that will process this, so we had this get articles and 33 00:02:50,300 --> 00:02:55,940 now we're going to get articles by category, which will be very similar to what we built there. 34 00:02:57,170 --> 00:02:58,220 So fun. 35 00:02:59,420 --> 00:03:03,140 Get articles by category. 36 00:03:04,190 --> 00:03:11,900 And we need to pass in the category and then we need to prepare our client with the API key. 37 00:03:14,150 --> 00:03:15,590 And then and cue. 38 00:03:16,780 --> 00:03:18,910 Actually, we need to do the same thing. 39 00:03:19,600 --> 00:03:21,820 So let me just. 40 00:03:22,830 --> 00:03:30,840 Put it in here like so so we need to get the API key, we get not top articles, but this time we get 41 00:03:31,140 --> 00:03:35,580 articles by category and we need to pass in the category here. 42 00:03:35,580 --> 00:03:41,790 So it's not going to be us always, which is not even a category, but we need to pass in the category 43 00:03:42,660 --> 00:03:43,500 name itself. 44 00:03:43,980 --> 00:03:48,810 So here we're passing the category and then we're passing the API key. 45 00:03:49,590 --> 00:03:52,740 So we need to use the service we NQ. 46 00:03:52,830 --> 00:03:56,790 We want to use a callback with top news response when we get the response. 47 00:03:57,390 --> 00:04:03,420 If it was successful, we're going to set our get article by category value to be the response body 48 00:04:03,840 --> 00:04:10,650 and we're going to display this as category like. 49 00:04:10,650 --> 00:04:18,450 So and if we get an error, we're going to display the response code or message either way is fine. 50 00:04:19,490 --> 00:04:19,970 Thanks so. 51 00:04:21,100 --> 00:04:26,380 And on failure, which is going to disprove a failure, so you see, it's pretty similar, but pretty 52 00:04:26,380 --> 00:04:26,980 much the same. 53 00:04:27,920 --> 00:04:33,410 Thing the only difference is that we're now passing the category in and not. 54 00:04:34,520 --> 00:04:35,030 The. 55 00:04:36,870 --> 00:04:37,620 Country anymore. 56 00:04:39,690 --> 00:04:41,130 And obviously, we're changing. 57 00:04:42,460 --> 00:04:43,540 A different variable. 58 00:04:43,780 --> 00:04:46,870 So we changed this variable that we have used here. 59 00:04:49,740 --> 00:04:55,750 And now we can actually use it in our newspaper and to be more precise in our. 60 00:04:57,210 --> 00:05:06,090 Bottom navigation one, we're working with the categories, so here we can now pass the news manager 61 00:05:06,390 --> 00:05:07,230 as we've done. 62 00:05:08,470 --> 00:05:18,610 And we can call our news manager thought, get articles by category where we pass it to it. 63 00:05:19,030 --> 00:05:24,910 So when we're fetching the category, it will get the selected category and then it will get the articles 64 00:05:24,910 --> 00:05:26,110 by that category. 65 00:05:27,490 --> 00:05:28,900 And then finally. 66 00:05:30,000 --> 00:05:39,000 When we load the page itself, so when we get to the categories route or categories page, we also need 67 00:05:39,000 --> 00:05:45,810 to get the articles by category like sole because I don't want the screen to be empty before we selected 68 00:05:45,810 --> 00:05:49,140 anything, and I'm just going to set the default to be business. 69 00:05:51,400 --> 00:05:59,590 And let's do the same thing with on selected category changed by default to be also business. 70 00:06:01,110 --> 00:06:01,620 Thanks so. 71 00:06:02,790 --> 00:06:03,460 OK. 72 00:06:03,480 --> 00:06:07,470 So let me see business like this, not double e, but double this. 73 00:06:08,400 --> 00:06:08,700 All right. 74 00:06:08,700 --> 00:06:12,030 This category does exist in our categories. 75 00:06:12,780 --> 00:06:18,700 And now if you run it and we check it out, we will see that we do get well. 76 00:06:18,810 --> 00:06:22,530 If we search for category, we do get content. 77 00:06:22,740 --> 00:06:26,670 So here we'll get our news, our international news. 78 00:06:27,360 --> 00:06:29,040 So Peter product, it's a look. 79 00:06:29,280 --> 00:06:33,240 So by Vienna 80, they have posted something and so forth. 80 00:06:33,240 --> 00:06:34,560 So we do get the data. 81 00:06:36,930 --> 00:06:38,460 Now we just need to display it. 82 00:06:38,880 --> 00:06:39,930 It should be. 83 00:06:40,560 --> 00:06:44,430 Should be instead of the cart where we have the roll with the modifier. 84 00:06:45,300 --> 00:06:50,280 Well, actually, this article countered Wait a second, so it should be in the categories page itself. 85 00:06:50,310 --> 00:06:52,430 So here we have our lazy roll. 86 00:06:52,800 --> 00:06:56,820 And under this lazy roll, that's where I want to display the article content. 87 00:06:57,270 --> 00:07:00,030 So I'm going to use my news manager. 88 00:07:01,050 --> 00:07:06,450 Don't get article by category, not value thought. 89 00:07:06,930 --> 00:07:07,590 Article. 90 00:07:08,960 --> 00:07:18,620 More articles, which will be a list of so if it's empty and just going to pass an empty list of things, 91 00:07:18,620 --> 00:07:18,860 so. 92 00:07:20,860 --> 00:07:22,810 OK, so now let's check it up again. 93 00:07:26,570 --> 00:07:28,370 And let's go over to the categories. 94 00:07:28,760 --> 00:07:29,570 And there we are. 95 00:07:29,690 --> 00:07:34,760 So now we see the business category content that we see the entertainment content. 96 00:07:36,100 --> 00:07:37,810 The general content and so forth. 97 00:07:38,500 --> 00:07:38,920 All right. 98 00:07:39,310 --> 00:07:43,720 So now we don't only load it, but we are also displaying it, so this part here is quite important. 99 00:07:45,040 --> 00:07:49,270 Well, we are actually using now our article content composable. 100 00:07:50,440 --> 00:07:50,800 All right. 101 00:07:50,980 --> 00:07:52,510 So that's it for this video. 102 00:07:52,930 --> 00:07:53,800 See you in the next one.