在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:Nsikaktopdown/AndelaChallengeProject开源软件地址:https://github.com/Nsikaktopdown/AndelaChallengeProject开源编程语言:Java 100.0%开源软件介绍:#AndelaChallengeProject Android app to retrieve a list of Java Developers in Lagos using the Github API Getting StartedYou can glone or download this project to your local machine. PrerequisitesIntermediate Android Experience Little or no experience with [Retrofit] (http://square.github.io/retrofit/) Library [GitHub API ] (https://api.github.com/search/users?q=language:java%20location:lagos) DependenciesObviously to use Retrofit you need this library in your dependencies. You also need a converter used for JSON format : Gson. Parceler is used for serialization and deserialization of objects.
GitHub Api Response in JSON
What do you need ?There is a minimum amount of files to write to request a Rest Api, you need at least one interface to write your query, a model to retrieve the api response and a restclient to make your calls. POJOyou need models to retrieve data from JSON returned by the server. You have to create POJOs, the fields name have to be the same as those in the JSON but you can have different names if you use @SerializedName annotation to specify the name of the field in the JSON. There is Serializable and Parcelable for serialization and deserialization of object.
ServiceYou have to create an interface called Service here to manage your url calls. In this interface you have to specify the type of the request like POST, GET, PUT, etc. For an asynchronized request you have to add a Callback to your methods and return void. To make the HTTp request we need to send some paramenters. In this case it is a query so we can also add
you will have to create your restclient object with your services.
public RestApiBuilder() { retrofit = new Retrofit.Builder() .baseUrl(BASE_URL) .addConverterFactory(GsonConverterFactory.create()) .build(); }
Authors
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论