So this is also done for us now all we have to implement is if we head over to one is the code in um like the actual java code so everything in the xml is done for us like the layout so let’s begin now we have one person oh yes i sure i’ll slow down uh so please let me know when you’re done and then we’ll begin and so if you are facing the problem so i um let me think is there some problem here so it should work so yes i’ll give it a few more a little while well honey we can’t hear you yes so i think there was a problem with the streaming service that we were using so hello everyone i yeah there was a bit of a problem here so for some reason the the there was some development the streaming that we had so i i hope it’s it’s fixed now you can yes perfect.
So now everything looks to be it’s working cool and this was actually the plan uh we actually were waiting so i was just doing something entertaining as like purposely causing problems so that person was downloading it can get some time so this was not a mistake folks this was very well planned and i’ll check it for my to-do list it worked in today’s session purposely fake problem and people will get some time to do to download the things cool so let’s let’s begin with that to do one so for if you head over to to do one on the to-do’s that we have here so under the under uh uh uh so and um so yeah so yeah all right so um it’s under retrofit so and the base package under retrofit we are going to go in this retrofit client instance and so here we are to do one so we are just returning this instance of retrofit here but we haven’t initialized it so this code is this boilerplate code so in case it seems a bit difficult don’t worry we have to just copy paste this in the future but if retrofit is equal to null.
So if it is not initialized let’s initialize it so you can head over to the solution code on github uh head over to the solution to the master branch under app and src under main and under uh java and here under retrofit so again if the path so again app src main then java then java and then retrofit so we are coding everything from here this retrofit client instance so you can just copy it from here if you want and uh yeah so we will just do it quickly here so new uh you can take help from from i’ve opened it in one other place too app src main java and it’s here so we’re going to use this retrofit builder which i also so i i i just um like sometimes if i forget i just copy paste this thing so for base url we already have the base url of the ui of the api that we’re going to use remember api is from where you’re going to download the internet the weather information so we just paste it here open weather api.
But add converter factory so again not enough going into what this is it’s this boilerplate code uh so this should work do something with the factory dot create dot create and then dot build so if it is null we initialize it we initialize this this retrofit instance and then we return it now why are we doing this so that way we just have one instance for the entire app because we only will call this method get instance and if it is null it will initialize it and return it and if it is not null it will skip this so it won’t initialize it again it will straight away return it so this is a good method to let’s have one instance of this retrofit uh one instance of any class throughout the entire app you can use this this trick all right this is done for one uh so now introduce two so we have this interface called api methods so uh here is is what’s going to happen this uh could seem a little complex.
But it’s fine like it it will be much more clear you know in some time so all that we did was we created this instance here this class for the instance we just wrote this if statement just to initialize it if it’s none then under this api methods interface here if you just i’ll just write it for now and then we’ll explain that soon if you want you can take the help from uh on github head back to retrofit this folder and head to retrofit client interface the java oops i mean api methods dot java and that’s what we’re going to do in 2-2 and so you get this is what we want to do likely and longitude so as it says here left double lag and at the right query which i’ll explain what this means let’s just do it for now lng so uh basically what’s going to happen is here we provided a base url right so i will copy this ctrl c and here in this second interface here there are two classes that you have to do for retrofit so in the second interface you see this long thing here right this is static so i’ll again do ctrl c so i’ve saved it on the clipboard now there’s something that changes in each call right the api key which is like a password so in this uh you can just think of it as a password that you’re going to use you can use my password if you want to save time um basically the thing that’s given the starting code is you shouldn’t save your password.
But i’m sharing it just so we can do it quickly um so the only thing that will change in our requests is what’s the latitude and the longitude which will depend on what location the user has entered so what i’m so what does that mean let’s head over and paste the base url that we have so this was the base url correct and then the path url in this oops the path url so there’s one more so one more thing that we have to add here is latitude and longitude so if you want to follow along you can um after the question mark you can type it l80 is equal to just type in anything like 30 point this is a lucky then type in an and an lng so if you are unfamiliar with this uh this is like how a url is usually formatted like from here to here it could be like the base url and everything with the slashes is called a path so data is in 2.5 so it’s a part this is a security refresher so we won’t go in too much in depth then the question mark everything after that is queries so latitude is equal to 30 point you know something and so you separate the queries with ampersand signs and longitude is this and here you can type in and exclude minutely