Rick And Morty App
Link to the api documentation: https://rickandmortyapi.com/
Technology / Others
- Couroutines
- JetPack Navigation Component
- Koin
- View Model
- RecyclerView
- Retrofit
- Live Data
- Core splashscreen
- MVVM
- Fragments
About the api / Sobre a api
Link to the api documentation: https://rickandmortyapi.com/
I used the following routes:
To get a single character with id:
I used this method to get a specify character:
@GET("character/{id}")
suspend fun getSingleCharacter(
@Path("id") id: String
): SingleCharacter
To get a list of characters, you need to specify the page number... Case you don't specify the api will give to you just first page. :
- https://rickandmortyapi.com/api/character (just a first page)
- https://rickandmortyapi.com/api/character/?page=2 (will bring up page 2)
I used this method to get a specify list:
@GET("character/")
suspend fun getListCharacter(
@Query("page") page: String
): ListCharacterResponse
Curiosities / Curiosidades
I would like to show a very cool curiosity about one of the items returned in the api object
The character's life status can be returned in 3 different strings Alive, Dead, Unknown... To validate this point, I created a class that sends a ready-made object with the colors, texts, and the image that should appear on the screen...
enum class StatusCharacter(
@StringRes val status: Int,
@ColorRes val textColor: Int,
@DrawableRes val iconImg: Int,
) {
STATUS_ALIVE(
status = R.string.txt_status_alive,
textColor = Color.GREEN,
iconImg = R.drawable.alive_status
),
STATUS_DEAD(
status = R.string.txt_status_dead,
textColor = Color.RED,
iconImg = R.drawable.dead_status
),
STATUS_UNKNOWN(
status = R.string.txt_status_unknown,
textColor = Color.GRAY,
iconImg = R.drawable.unknow_status
)
}