SlideShare a Scribd company logo
Retrofit 2
Bruno Vieira
O que devemos saber
New Url Pattern
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
https://api.dribbble.com/shots?access_token=...
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1/")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1/")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1/")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
New Url Pattern
public interface WebServiceApi{
@GET("shots")
Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken);
}
public class WebServiceManagerImpl implements WebServiceManager {
private void setupApi() {
Retrofit retrofit = new Retrofit.Builder()
.baseUrl("https://api.dribbble.com/v1/")
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
webServiceApi = retrofit.create(WebServiceApi.class);
}
}
https://api.dribbble.com/v1/shots?access_token=...
New Url Pattern
Dynamic URL
public interface WebServiceApi{
@GET
Call<JokeVO> getAJoke(@Url String url);
}
Bippples
https://github.com/OBrunoVieira/Bippples
Dribbble
+
Chuck Norris Database
https://github.com/OBrunoVieira/Bippples
Bippples
https://github.com/OBrunoVieira/Bippples
OkHttp
OkHttp
Retrofit 1.9 - Is optional
Retrofit 2.x - Is required
Importing a specific version:
compile ('com.squareup.retrofit2:retrofit:2.0.2') {
exclude module: 'okhttp'
}
compile 'com.squareup.okhttp3:okhttp:3.2.0'
OkHttp
Interceptors
public OkHttpClient clientInterceptor() {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(this);
...
return httpClient.build();
}
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
request = request.newBuilder()
.addHeader("Authorization", "123454324rtxccvbfdsfgvbcx!@#!@#!@#")
.build();
return chain.proceed(request);
}
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Environment.SERVER_URL)
.client(clientInterceptor())
.build();
OkHttp
Interceptors
public OkHttpClient clientInterceptor() {
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(this);
...
return httpClient.build();
}
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
request = request.newBuilder()
.addHeader("Authorization", "123454324rtxccvbfdsfgvbcx!@#!@#!@#")
.build();
return chain.proceed(request);
}
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Environment.SERVER_URL)
.client(clientInterceptor())
.build();
OkHttp.Interceptors
No Logging
OkHttp.Interceptors
No Logging, but..
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
public OkHttpClient clientInterceptor() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(Environment.LOG_LEVEL);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(interceptor);
...
return httpClient.build();
}
OkHttp.Interceptors
No Logging, but..
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
public OkHttpClient clientInterceptor() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(Environment.LOG_LEVEL);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(interceptor);
...
return httpClient.build();
}
OkHttp.Interceptors
No Logging, but..
compile 'com.squareup.okhttp3:logging-interceptor:3.2.0'
public OkHttpClient clientInterceptor() {
HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor();
interceptor.setLevel(Environment.LOG_LEVEL);
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
httpClient.addInterceptor(interceptor);
...
return httpClient.build();
}
Converters
Converters
No converter by default
compile "com.github.aurae.retrofit2:converter-logansquare:1.4.0"
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Environment.SERVER_URL)
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
Converters
No converter by default
compile "com.github.aurae.retrofit2:converter-logansquare:1.4.0"
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(Environment.SERVER_URL)
.addConverterFactory(LoganSquareConverterFactory.create())
.client(webServiceInterceptor.clientInterceptor())
.build();
Requests
Requests
Synchronous and Asynchronous
Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken);
List<ShotsVO> shotsList = call.execute.body;
Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken);
call.enqueue(new Callback<List<ShotsVO>>(){
@Override
public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){
...
}
...
}
Requests
Attention!
Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken);
call.enqueue(new Callback<List<ShotsVO>>(){
@Override
public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){
...
}
@Override
public void onFailure(Call<List<ShotsVO>> call, Throwable throwable) {
...
}
}
https://github.com/OBrunoVieira/Bippples
Requests
Cancel
Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken);
call.enqueue(new Callback<List<ShotsVO>>(){
@Override
public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){
...
}
@Override
public void onFailure(Call<List<ShotsVO>> call, Throwable throwable) {
...
}
}
call.cancel();
Requests
Cancel
Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken);
call.enqueue(new Callback<List<ShotsVO>>(){
@Override
public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){
...
}
@Override
public void onFailure(Call<List<ShotsVO>> call, Throwable throwable) {
...
}
}
call.cancel();
=)
Source
http://square.github.io/retrofit/
https://inthecheesefactory.com/blog/retrofit-2.0/en
http://www.iayon.com/consuming-rest-api-with-retrofit-2-0-in-
android/
https://github.com/square/retrofit/blob/master/CHANGELOG.md
www.concretesolutions.com.br
blog.concretesolutions.com.br
Rio de Janeiro – Rua São José, 90 – cj. 2121
Centro – (21) 2240-2030
São Paulo - Rua Sansão Alves dos Santos, 433
4º andar - Brooklin - (11) 4119-0449

More Related Content

What's hot

Service Oriented Web Development with OSGi - C Ziegeler
Service Oriented Web Development with OSGi - C ZiegelerService Oriented Web Development with OSGi - C Ziegeler
Service Oriented Web Development with OSGi - C Ziegeler
mfrancis
 
Sensu wrapper-sensu-summit
Sensu wrapper-sensu-summitSensu wrapper-sensu-summit
Sensu wrapper-sensu-summit
Lee Briggs
 
How to send gzipped requests with boto3
How to send gzipped requests with boto3How to send gzipped requests with boto3
How to send gzipped requests with boto3
Luciano Mammino
 
Asynchronen Code testen
Asynchronen Code testenAsynchronen Code testen
Asynchronen Code testen
ndrssmn
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
David Chandler
 
HTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The DeadHTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The Dead
noamt
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
noamt
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Red Hat Developers
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
Fabio Akita
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
Andres Almiray
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
Andres Almiray
 
Analysing Github events with Neo4j
Analysing Github events with Neo4jAnalysing Github events with Neo4j
Analysing Github events with Neo4j
Christophe Willemsen
 
Salesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP calloutsSalesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP callouts
RAMNARAYAN R
 
Rntb20200805
Rntb20200805Rntb20200805
Rntb20200805
t k
 
React native-firebase startup-mtup
React native-firebase startup-mtupReact native-firebase startup-mtup
React native-firebase startup-mtup
t k
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
Bartosz Sypytkowski
 
Spark Day 2017- Spark 의 과거, 현재, 미래
Spark Day 2017- Spark 의 과거, 현재, 미래Spark Day 2017- Spark 의 과거, 현재, 미래
Spark Day 2017- Spark 의 과거, 현재, 미래
Moon Soo Lee
 
Shibuya,trac セッション
Shibuya,trac セッションShibuya,trac セッション
Shibuya,trac セッション
Yasunobu Kawaguchi
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
Graham Dumpleton
 
NestJS
NestJSNestJS
NestJS
Wilson Su
 

What's hot (20)

Service Oriented Web Development with OSGi - C Ziegeler
Service Oriented Web Development with OSGi - C ZiegelerService Oriented Web Development with OSGi - C Ziegeler
Service Oriented Web Development with OSGi - C Ziegeler
 
Sensu wrapper-sensu-summit
Sensu wrapper-sensu-summitSensu wrapper-sensu-summit
Sensu wrapper-sensu-summit
 
How to send gzipped requests with boto3
How to send gzipped requests with boto3How to send gzipped requests with boto3
How to send gzipped requests with boto3
 
Asynchronen Code testen
Asynchronen Code testenAsynchronen Code testen
Asynchronen Code testen
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
 
HTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The DeadHTTPBuilder NG: Back From The Dead
HTTPBuilder NG: Back From The Dead
 
Groovy Powered Clean Code
Groovy Powered Clean CodeGroovy Powered Clean Code
Groovy Powered Clean Code
 
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech TalkContract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
Contract-driven development with OpenAPI 3 and Vert.x | DevNation Tech Talk
 
Tdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema RubyTdc 2013 - Ecossistema Ruby
Tdc 2013 - Ecossistema Ruby
 
Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017Making the most of your gradle build - Gr8Conf 2017
Making the most of your gradle build - Gr8Conf 2017
 
Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017Making the most of your gradle build - Greach 2017
Making the most of your gradle build - Greach 2017
 
Analysing Github events with Neo4j
Analysing Github events with Neo4jAnalysing Github events with Neo4j
Analysing Github events with Neo4j
 
Salesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP calloutsSalesforce Integration using REST SOAP and HTTP callouts
Salesforce Integration using REST SOAP and HTTP callouts
 
Rntb20200805
Rntb20200805Rntb20200805
Rntb20200805
 
React native-firebase startup-mtup
React native-firebase startup-mtupReact native-firebase startup-mtup
React native-firebase startup-mtup
 
Behind modern concurrency primitives
Behind modern concurrency primitivesBehind modern concurrency primitives
Behind modern concurrency primitives
 
Spark Day 2017- Spark 의 과거, 현재, 미래
Spark Day 2017- Spark 의 과거, 현재, 미래Spark Day 2017- Spark 의 과거, 현재, 미래
Spark Day 2017- Spark 의 과거, 현재, 미래
 
Shibuya,trac セッション
Shibuya,trac セッションShibuya,trac セッション
Shibuya,trac セッション
 
PyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web ApplicationsPyCon AU 2012 - Debugging Live Python Web Applications
PyCon AU 2012 - Debugging Live Python Web Applications
 
NestJS
NestJSNestJS
NestJS
 

Viewers also liked

Volley vs Retrofit
Volley vs RetrofitVolley vs Retrofit
Volley vs Retrofit
Facundo Rodríguez Arceri
 
introduce Okhttp
introduce Okhttpintroduce Okhttp
introduce Okhttp
朋 王
 
Simplificando chamadas HTTP com o Retrofit
Simplificando chamadas HTTP com o RetrofitSimplificando chamadas HTTP com o Retrofit
Simplificando chamadas HTTP com o Retrofit
Felipe Pedroso
 
Retrofit
RetrofitRetrofit
Retrofit
Amin Cheloh
 
Realm @Android
Realm @Android Realm @Android
Realm @Android
Theodore(Yongbin) Cha
 
Android DevConference - Dagger 2: uso avançado em projetos Android
Android DevConference - Dagger 2: uso avançado em projetos AndroidAndroid DevConference - Dagger 2: uso avançado em projetos Android
Android DevConference - Dagger 2: uso avançado em projetos Android
iMasters
 
Retro vs Volley
Retro vs VolleyRetro vs Volley
Retro vs Volley
Artjoker
 
Visteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisasVisteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisas
José María Pérez Ramos
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
Tomáš Kypta
 
大鱼架构演进
大鱼架构演进大鱼架构演进
大鱼架构演进
Jun Liu
 
Reactive programming with RxJava
Reactive programming with RxJavaReactive programming with RxJava
Reactive programming with RxJava
Jobaer Chowdhury
 
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃんRetrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
Yukari Sakurai
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
Andres Almiray
 
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Manjong Han
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
Tomáš Kypta
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & design
allegro.tech
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
Tomáš Kypta
 
Seismic retrofit methods
Seismic retrofit methodsSeismic retrofit methods
Seismic retrofit methods
Paul McMullin
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
Ali Muzaffar
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
José Paumard
 

Viewers also liked (20)

Volley vs Retrofit
Volley vs RetrofitVolley vs Retrofit
Volley vs Retrofit
 
introduce Okhttp
introduce Okhttpintroduce Okhttp
introduce Okhttp
 
Simplificando chamadas HTTP com o Retrofit
Simplificando chamadas HTTP com o RetrofitSimplificando chamadas HTTP com o Retrofit
Simplificando chamadas HTTP com o Retrofit
 
Retrofit
RetrofitRetrofit
Retrofit
 
Realm @Android
Realm @Android Realm @Android
Realm @Android
 
Android DevConference - Dagger 2: uso avançado em projetos Android
Android DevConference - Dagger 2: uso avançado em projetos AndroidAndroid DevConference - Dagger 2: uso avançado em projetos Android
Android DevConference - Dagger 2: uso avançado em projetos Android
 
Retro vs Volley
Retro vs VolleyRetro vs Volley
Retro vs Volley
 
Visteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisasVisteme con 'Clean Architecture' que tengo prisas
Visteme con 'Clean Architecture' que tengo prisas
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
大鱼架构演进
大鱼架构演进大鱼架构演进
大鱼架构演进
 
Reactive programming with RxJava
Reactive programming with RxJavaReactive programming with RxJava
Reactive programming with RxJava
 
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃんRetrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
Retrofit2 &OkHttp 
でAndroidのHTTP通信が快適だにゃん
 
Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss Java Libraries You Can’t Afford to Miss
Java Libraries You Can’t Afford to Miss
 
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
Flask, Redis, Retrofit을 이용한 Android 로그인 서비스 구현하기
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
RxJava - introduction & design
RxJava - introduction & designRxJava - introduction & design
RxJava - introduction & design
 
Reactive programming on Android
Reactive programming on AndroidReactive programming on Android
Reactive programming on Android
 
Seismic retrofit methods
Seismic retrofit methodsSeismic retrofit methods
Seismic retrofit methods
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
 

Similar to Retrofit 2 - O que devemos saber

Web api's
Web api'sWeb api's
Web api's
umesh patil
 
Advanced #2 networking
Advanced #2   networkingAdvanced #2   networking
Advanced #2 networking
Vitali Pekelis
 
ASP.NET MVC Internals
ASP.NET MVC InternalsASP.NET MVC Internals
ASP.NET MVC Internals
Vitaly Baum
 
Servlets
ServletsServlets
Servlets
Geethu Mohan
 
Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
Toshiaki Maki
 
Automated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.xAutomated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.x
Tatsuya Maki
 
Quick Fetch API Introduction
Quick Fetch API IntroductionQuick Fetch API Introduction
Quick Fetch API Introduction
Chris Love
 
Android dev 3
Android dev 3Android dev 3
Android dev 3
Aravindharamanan S
 
CDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptor
Caelum
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
IMC Institute
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
Matt Raible
 
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R AugeHTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
mfrancis
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_service
NCCOMMS
 
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdfAPI 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
ssuserb6c2641
 
Web CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docx
Web CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docxWeb CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docx
Web CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docx
celenarouzie
 
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
Fons Sonnemans
 
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC#46 一探 C# 11 與 .NET 7 的神奇twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC
 
Connecting to the network
Connecting to the networkConnecting to the network
Connecting to the network
Mu Chun Wang
 
FrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftFrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) Swift
Chris Bailey
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
Loiane Groner
 

Similar to Retrofit 2 - O que devemos saber (20)

Web api's
Web api'sWeb api's
Web api's
 
Advanced #2 networking
Advanced #2   networkingAdvanced #2   networking
Advanced #2 networking
 
ASP.NET MVC Internals
ASP.NET MVC InternalsASP.NET MVC Internals
ASP.NET MVC Internals
 
Servlets
ServletsServlets
Servlets
 
Implement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyoImplement Service Broker with Spring Boot #cf_tokyo
Implement Service Broker with Spring Boot #cf_tokyo
 
Automated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.xAutomated%20testing%20with%20Espresso2.x
Automated%20testing%20with%20Espresso2.x
 
Quick Fetch API Introduction
Quick Fetch API IntroductionQuick Fetch API Introduction
Quick Fetch API Introduction
 
Android dev 3
Android dev 3Android dev 3
Android dev 3
 
CDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptorCDI e as ideias pro futuro do VRaptor
CDI e as ideias pro futuro do VRaptor
 
Java Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet BasicJava Web Programming [2/9] : Servlet Basic
Java Web Programming [2/9] : Servlet Basic
 
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 202010 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
10 Excellent Ways to Secure Spring Boot Applications - Okta Webinar 2020
 
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R AugeHTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
HTTP Whiteboard - OSGI Compendium 6.0 - How web apps should have been! - R Auge
 
Spca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_serviceSpca2014 hillier build your_own_rest_service
Spca2014 hillier build your_own_rest_service
 
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdfAPI 통신, Retrofit 대신 Ktor 어떠신가요.pdf
API 통신, Retrofit 대신 Ktor 어떠신가요.pdf
 
Web CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docx
Web CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docxWeb CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docx
Web CrawlersrcedusmulylecrawlerController.javaWeb Crawler.docx
 
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
TechDays 2016 - Developing websites using asp.net core mvc6 and entity framew...
 
twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC#46 一探 C# 11 與 .NET 7 的神奇twMVC#46 一探 C# 11 與 .NET 7 的神奇
twMVC#46 一探 C# 11 與 .NET 7 的神奇
 
Connecting to the network
Connecting to the networkConnecting to the network
Connecting to the network
 
FrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) SwiftFrenchKit 2017: Server(less) Swift
FrenchKit 2017: Server(less) Swift
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 

Recently uploaded

Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
Trending Blogers
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
wolfsoftcompanyco
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
davidjhones387
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
fovkoyb
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Florence Consulting
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
Toptal Tech
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
cuobya
 
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
ysasp1
 
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
uehowe
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
hackersuli
 
留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理
留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理
留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理
bseovas
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
vmemo1
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
bseovas
 
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
ukwwuq
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
zyfovom
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
Laura Szabó
 
Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
Trish Parr
 
Azure EA Sponsorship - Customer Guide.pdf
Azure EA Sponsorship - Customer Guide.pdfAzure EA Sponsorship - Customer Guide.pdf
Azure EA Sponsorship - Customer Guide.pdf
AanSulistiyo
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
Paul Walk
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
Danica Gill
 

Recently uploaded (20)

Explore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories SecretlyExplore-Insanony: Watch Instagram Stories Secretly
Explore-Insanony: Watch Instagram Stories Secretly
 
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaalmanuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
manuaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaal
 
Discover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to IndiaDiscover the benefits of outsourcing SEO to India
Discover the benefits of outsourcing SEO to India
 
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
存档可查的(USC毕业证)南加利福尼亚大学毕业证成绩单制做办理
 
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdfMeet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
Meet up Milano 14 _ Axpo Italia_ Migration from Mule3 (On-prem) to.pdf
 
Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!Ready to Unlock the Power of Blockchain!
Ready to Unlock the Power of Blockchain!
 
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
假文凭国外(Adelaide毕业证)澳大利亚国立大学毕业证成绩单办理
 
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
成绩单ps(UST毕业证)圣托马斯大学毕业证成绩单快速办理
 
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
留学挂科(UofM毕业证)明尼苏达大学毕业证成绩单复刻办理
 
[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024[HUN][hackersuli] Red Teaming alapok 2024
[HUN][hackersuli] Red Teaming alapok 2024
 
留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理
留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理
留学学历(UoA毕业证)奥克兰大学毕业证成绩单官方原版办理
 
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
重新申请毕业证书(RMIT毕业证)皇家墨尔本理工大学毕业证成绩单精仿办理
 
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
不能毕业如何获得(USYD毕业证)悉尼大学毕业证成绩单一比一原版制作
 
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
制作原版1:1(Monash毕业证)莫纳什大学毕业证成绩单办理假
 
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
学位认证网(DU毕业证)迪肯大学毕业证成绩单一比一原版制作
 
Gen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needsGen Z and the marketplaces - let's translate their needs
Gen Z and the marketplaces - let's translate their needs
 
Search Result Showing My Post is Now Buried
Search Result Showing My Post is Now BuriedSearch Result Showing My Post is Now Buried
Search Result Showing My Post is Now Buried
 
Azure EA Sponsorship - Customer Guide.pdf
Azure EA Sponsorship - Customer Guide.pdfAzure EA Sponsorship - Customer Guide.pdf
Azure EA Sponsorship - Customer Guide.pdf
 
Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?Should Repositories Participate in the Fediverse?
Should Repositories Participate in the Fediverse?
 
7 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 20247 Best Cloud Hosting Services to Try Out in 2024
7 Best Cloud Hosting Services to Try Out in 2024
 

Retrofit 2 - O que devemos saber

  • 1. Retrofit 2 Bruno Vieira O que devemos saber
  • 3. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } }
  • 4. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } }
  • 5. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } }
  • 6. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } } https://api.dribbble.com/shots?access_token=...
  • 7. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1/") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } }
  • 8. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1/") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } }
  • 9. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1/") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } }
  • 10. New Url Pattern public interface WebServiceApi{ @GET("shots") Call<List<ShotsVO>> getShotsList(@Query("access_token") String accessToken); } public class WebServiceManagerImpl implements WebServiceManager { private void setupApi() { Retrofit retrofit = new Retrofit.Builder() .baseUrl("https://api.dribbble.com/v1/") .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build(); webServiceApi = retrofit.create(WebServiceApi.class); } } https://api.dribbble.com/v1/shots?access_token=...
  • 11. New Url Pattern Dynamic URL public interface WebServiceApi{ @GET Call<JokeVO> getAJoke(@Url String url); }
  • 15. OkHttp Retrofit 1.9 - Is optional Retrofit 2.x - Is required Importing a specific version: compile ('com.squareup.retrofit2:retrofit:2.0.2') { exclude module: 'okhttp' } compile 'com.squareup.okhttp3:okhttp:3.2.0'
  • 16. OkHttp Interceptors public OkHttpClient clientInterceptor() { OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(this); ... return httpClient.build(); } public Response intercept(Chain chain) throws IOException { Request request = chain.request(); request = request.newBuilder() .addHeader("Authorization", "123454324rtxccvbfdsfgvbcx!@#!@#!@#") .build(); return chain.proceed(request); } Retrofit retrofit = new Retrofit.Builder() .baseUrl(Environment.SERVER_URL) .client(clientInterceptor()) .build();
  • 17. OkHttp Interceptors public OkHttpClient clientInterceptor() { OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(this); ... return httpClient.build(); } public Response intercept(Chain chain) throws IOException { Request request = chain.request(); request = request.newBuilder() .addHeader("Authorization", "123454324rtxccvbfdsfgvbcx!@#!@#!@#") .build(); return chain.proceed(request); } Retrofit retrofit = new Retrofit.Builder() .baseUrl(Environment.SERVER_URL) .client(clientInterceptor()) .build();
  • 19. OkHttp.Interceptors No Logging, but.. compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' public OkHttpClient clientInterceptor() { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(Environment.LOG_LEVEL); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(interceptor); ... return httpClient.build(); }
  • 20. OkHttp.Interceptors No Logging, but.. compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' public OkHttpClient clientInterceptor() { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(Environment.LOG_LEVEL); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(interceptor); ... return httpClient.build(); }
  • 21. OkHttp.Interceptors No Logging, but.. compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' public OkHttpClient clientInterceptor() { HttpLoggingInterceptor interceptor = new HttpLoggingInterceptor(); interceptor.setLevel(Environment.LOG_LEVEL); OkHttpClient.Builder httpClient = new OkHttpClient.Builder(); httpClient.addInterceptor(interceptor); ... return httpClient.build(); }
  • 23. Converters No converter by default compile "com.github.aurae.retrofit2:converter-logansquare:1.4.0" Retrofit retrofit = new Retrofit.Builder() .baseUrl(Environment.SERVER_URL) .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build();
  • 24. Converters No converter by default compile "com.github.aurae.retrofit2:converter-logansquare:1.4.0" Retrofit retrofit = new Retrofit.Builder() .baseUrl(Environment.SERVER_URL) .addConverterFactory(LoganSquareConverterFactory.create()) .client(webServiceInterceptor.clientInterceptor()) .build();
  • 26. Requests Synchronous and Asynchronous Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken); List<ShotsVO> shotsList = call.execute.body; Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken); call.enqueue(new Callback<List<ShotsVO>>(){ @Override public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){ ... } ... }
  • 27. Requests Attention! Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken); call.enqueue(new Callback<List<ShotsVO>>(){ @Override public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){ ... } @Override public void onFailure(Call<List<ShotsVO>> call, Throwable throwable) { ... } } https://github.com/OBrunoVieira/Bippples
  • 28. Requests Cancel Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken); call.enqueue(new Callback<List<ShotsVO>>(){ @Override public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){ ... } @Override public void onFailure(Call<List<ShotsVO>> call, Throwable throwable) { ... } } call.cancel();
  • 29. Requests Cancel Call<List<ShotsVO>> call = webServiceManager.getWebServiceApiInstance().getShotsList(accessToken); call.enqueue(new Callback<List<ShotsVO>>(){ @Override public void onResponse(Call<List<ShotsVO>> call, Response<List<ShotsVO>> response){ ... } @Override public void onFailure(Call<List<ShotsVO>> call, Throwable throwable) { ... } } call.cancel();
  • 30. =)
  • 32. www.concretesolutions.com.br blog.concretesolutions.com.br Rio de Janeiro – Rua São José, 90 – cj. 2121 Centro – (21) 2240-2030 São Paulo - Rua Sansão Alves dos Santos, 433 4º andar - Brooklin - (11) 4119-0449