This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SampleRetrofitInterface api = SampleRetrofitInterface.retrofit.create(SampleRetrofitInterface.class); | |
Call<List<Post>> call = api.getPostList(); | |
call.enqueue(new Callback<List<Post>>() { | |
@Override | |
public void onResponse(Call<List<Post>>call, Response<List<Post>> response) { | |
Log.i("INFO", String.valueOf(response.body().size())); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Post { | |
int userId; | |
int id; | |
String title; | |
String body; | |
public Post(int userId, int id, String title, String body) { | |
this.userId = userId; | |
this.id = id; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"userId": 1, | |
"id": 1, | |
"title": "sunt aut facere repellat provident occaecati excepturi optio reprehenderit", | |
"body": "quia et suscipit\nsuscipit recusandae consequuntur expedita et cum\nreprehenderit molestiae ut ut quas totam\nnostrum rerum est autem sunt rem eveniet architecto" | |
}, | |
{ | |
"userId": 1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface SampleRetrofitInterface { | |
@GET("/posts") | |
Call<List<Post>> getPostList(); | |
@GET("/posts/{id}") | |
Call<Post> getSinglePost(@Path("id") int postId); | |
@GET("/posts/") | |
Call<Post> getSinglePostQuery(@Query("userId") int userId); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
implementation 'com.android.support:appcompat-v7:27.0.2' | |
implementation 'com.android.support:recyclerview-v7:27.0.2' | |
implementation "com.jakewharton:butterknife:8.8.1" | |
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
project.ext { | |
applicationId = "jensklingenberg.de.exampleexoplayer" | |
compileSdk = 27 | |
targetSdk = 27 | |
minSdk = 21 | |
versionCode = 1 | |
versionName = "1.0" | |
buildTools = '27.0.1' | |
junitVersion = '4.12' | |
appVersion = '1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies { | |
... | |
implementation "com.android.support:appcompat-v7:${supportLibVersion}" | |
implementation "com.google.android.exoplayer:exoplayer:${exoplayerVersion}" | |
implementation "com.jakewharton:butterknife:${butterknifeVersion}" | |
annotationProcessor "com.jakewharton:butterknife-compiler:${butterknifeVersion}"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compileSdkVersion compileSdk | |
defaultConfig { | |
applicationId applicationId | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildTypes { | |
debug { | |
buildConfigField "String", "API_BASE_URL", '"https://test.de/testing/api/v1/"' | |
... | |
} | |
release { | |
buildConfigField "String", "API_BASE_URL", '"https://test.de/prod/api/v1/"' | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new Retrofit.Builder().addConverterFactory(MoshiConverterFactory.create(moshi)) | |
.addCallAdapterFactory(new LiveDataCallAdapterFactory()) | |
.baseUrl(BuildConfig.API_BASE_URL) | |
.client(App.getInstance().getOkHttpClient()) | |
.build(); |
OlderNewer