-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Retrofit example and removed unused button
- Loading branch information
Showing
4 changed files
with
51 additions
and
47 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
app/src/main/java/com/livinglifetechway/k4kotlinsample/ApiInterface.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.livinglifetechway.k4kotlinsample.RetrofitApi | ||
|
||
import retrofit2.Call | ||
import retrofit2.http.GET | ||
|
||
/** | ||
*/ | ||
interface ApiInterface { | ||
@GET("posts/1") | ||
fun getPost(): Call<Post> | ||
|
||
@GET("users") | ||
fun getUserDetails(): Call<UserResp> | ||
|
||
@GET("aaaa/bbbb") | ||
fun getUserDetailsError(): Call<UserResp> | ||
|
||
} | ||
|
||
|
||
data class Post( | ||
val userId: Int, //1 | ||
val id: Int, //1 | ||
val title: String, //sunt aut facere repellat provident occaecati excepturi optio reprehenderit | ||
val body: String //quia et suscipit suscipit recusandae consequuntur expedita et cum reprehenderit molestiae ut ut quas totam nostrum rerum est autem sunt rem eveniet architecto | ||
) | ||
|
||
data class UserResp( | ||
val page: Int, //2 | ||
val per_page: Int, //3 | ||
val total: Int, //12 | ||
val total_pages: Int, //4 | ||
val data: List<Data> | ||
) | ||
|
||
data class Data( | ||
val id: Int, //4 | ||
val first_name: String, //Eve | ||
val last_name: String, //Holt | ||
val avatar: String //https://s3.amazonaws.com/uifaces/faces/twitter/marcoramires/128.jpg | ||
) |
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
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
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