‫Hello, my friends.
‫In this part we will continue making our application and we will implement the networking section.
‫So we will use the retrofit library.
‫Our old friend.
‫We have seen in the previous videos about using retrofit library, which is a very good library that
‫helps us in order to get the Http responses and get get using the API responses, Json and other formats.
‫So also we will learn and use the Json, which is the serialization responsible for serialization and
‫deserialization of the responses.
‫We go to the square dot Github.io slash retrofit.
‫If you don't know anything about retrofit, please go back to the course to the playlists and courses
‫Section 16 on Udemy and 15 and search for the retrofit.
‫It is full functional application using retrofit.
‫And it is good for now too, to know how to use it and how to download it and integrate it with our
‫application.
‫So I will copy this and I will go to the gradle.
‫I will scroll down and paste the implementation.
‫We have an insert, insert latest version.
‫I will remove it and I go back to that to the side and see the latest version.
‫Okay, I need to get the latest version of the retrofit.
‫And we click on the GitHub icon.
‫In the above and we scroll down.
‫This is the GitHub for the retrofit and we see it.
‫It is 2.9.0.
‫Copy and paste it.
‫Also, as I mentioned before, we need to add serializer and deserializer for the and converters for
‫using the retrofit.
‫So by default retrofit can only deserialize http bodies into a Http response body type and it can only
‫accept the request body type for body annotation.
‫The converters can be added to support other types.
‫We have these six.
‫I will use the Json, which is I think it is the best and I will add it implementation and the square
‫root Json retrofit.
‫And I will add a version for it.
‫It is.
‫I think to point at the same as the retrofit sink.
‫Now things sink the project.
‫I think that is an error because we didn't implement the right version.
‫I will go to the code of Json, scroll down and it is 2.86.
‫Okay.
‫I will make the converter.
‫I need the converter.
‫So I will.
‫Add the converter.
‫I think it is not the.
‫It is the same version as retrofit.
‫Okay.
‫So the error is here.
‫Okay.
‫Implementation.
‫I o.
‫Sorry for that.
‫For now.
‫2.9.0. the Json converter would be the same as the retrofit.
‫Okay.
‫And importing gradle projects.
‫Okay.
‫Till now, we have implemented the the libraries for the retrofit.
‫Now the dependency for the retrofit, I will add a Stack overflow API.
‫But first, let me show you how retrofit will fetch the stack overflow and in which type and in which
‫format and what data we need to get from a stack overflow.
‫If we search on google about the API.
‫StackOverflow API, you will be directed to api.stackexchange.com/documents.
‫This documents is fully a fully lectured and full detailed about the data that this API.
‫The StackOverflow API will deliver for you.
‫So if we implement the API for the StackOverflow.
‫What kind of data we will get and what are the possibilities of data that we will get.
‫You will see on the right side how to configure the authentication, the JavaScript SDK.
‫Batching requests, complex queries, filters, duplicate requests, paging data dates, numbers, compression,
‫and many, many data.
‫So.
‫If we see that all API response are Json.
‫I will highlight the the data that we need and they are very important.
‫Every response in the in the API is returned in a common wrapper object for easier and more consistent.
‫Passing.
‫We have dealt with the wrapper objects and the model class that we will fetch the Json in it and then
‫we will get it with the retrofit and display them into recycler view.
‫The same way we will implement this that we have learned in this application.
‫So our our concentration will not be on a networking either.
‫On UI, we will concentrate about dependency injection and how to make the architecture of our application
‫looks clean and professional.
‫So.
‫A number of number of few methods which require the application be acting on behalf of the user in order
‫to be invoked.
‫The some methods requires and requires authentication, others not.
‫We will use the the not requiring the authentication.
‫So.
‫If we see here, scroll down and we see that this method type for answers.
‫So each of these methods operates as on single side at a time.
‫This will get.
‫A the answers.
‫Get all answers on the side.
‫Get the answers identified by a set of IDs.
‫You see, guys, this is the variable that we will deal with it.
‫And you see guys, here are the answers that required the authentication required.
‫So you need to to authenticate and the login in order to use this.
‫So comments, answers, edits, everything about the answers.
‫If you scroll down, we see also a badge section.
‫So we get all badges on the side in alphabetical orders identified by IDs badges that that are tagged
‫recently awarded on site, recently recipient, recipient of given badges and more and more things.
‫If we scroll down also we get the comments section.
‫So the the comment section, get all comments on the side, get all comments identified by a set of
‫ID and these are more and more options.
‫If also scroll down, we see events, info posts, privileges and questions and for what we need.
‫And if I scroll down revision search suggested edits tags users you can get data about users and and
‫many others, but what we need in our application is the questions section.
‫So the questions section is what we need and what we are concerned.
‫Okay, so.
‫You see guys questions, you can get all questions on site.
‫Let me click on it and open it on another tab.
‫And the sort accepted.
‫You can sort the object, you can try it here.
‫So.
‫The link.
‫Before.
‫As I told you in the previous courses about retrofit that there is a fixed link.
‫Which will be in the constant class and a variable length that will be in the that will be a depending
‫on our request.
‫So when the user enter in a search search view or if you scroll down or you are requesting more and
‫more pages, all are done by the requests that it is in the variable part.
‫Don't worry, we will see them clearly on our application.
‫One Implementing this I will notify you and don't worry again.
‫Everything will be fine and everything will be lectured at the proper, proper time.
‫So if I try to page one, you see guys, the request has been adding a page variable and given it one.
‫So if I give five it will be five one.
‫I will give it one and I will click run.
‫You see guys, I have got an items array.
‫Of Jason.
‫So this is adjacent, as I told you, Jason, and this is the name of array.
‫It's called items.
‫And inside this array items, I have objects.
‫Of type and Jason and Jason.
‫And it is named Tag.
‫It is an array.
‫Also an array.
‫Having these and we have an owner.
‫It is also an object having link, display, name, profile, name and the other of the owner.
‫And these are also other thing.
‫What we need from this is the title and the question ID So I will search for the question ID here and
‫the title.
‫So the question ID and the.
‫Sorry, the title and the question ID, I will display the title in recycler view and the question ID
‫I will pass it when the user click on on the on any question, it will be passing the question ID to
‫the details activity and the details activity.
‫Go take the ID and make another response.
‫Another call, another retrofit call that requires the data for from the API of the of StackOverflow
‫and getting them back, displaying them using retrofit to the details activity.
‫This is the the an overview of our application.
‫So our application will have the title of the questions of questions and the ID.
‫This is the main activity, this is the question list activity.
‫And when the user click on any question, the ID will be the ID of the question will be passed.
‫And again, it would be running and retrofit an API call using retrofit and it will passing again the
‫Json data details activity.
‫It will be displaying the these data.
‫I hope you understand it.
‫Now let's go and configure our application on Android studio.
‫But before this are you can add them, you can read about them, you can test them and much more.
‫Back to Android studio.
‫We have done this and we have done this.
‫I will configure the question class.