-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/pr task #1
base: main
Are you sure you want to change the base?
Conversation
implementation(libs.retrofit.kotlinx.serialization.converter) | ||
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to libs.versions.toml
@@ -4,13 +4,18 @@ import com.jakewharton.retrofit2.converter.kotlinx.serialization.asConverterFact | |||
import kotlinx.serialization.ExperimentalSerializationApi | |||
import kotlinx.serialization.json.Json | |||
import okhttp3.MediaType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import
private val json = Json { | ||
ignoreUnknownKeys = true | ||
isLenient = true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is crucial change and it's not directly connected with "logging".
Why do we need lenient
mode?
import retrofit2.Retrofit | ||
|
||
class ApiService { | ||
|
||
private val contentType = MediaType.get("application/json") | ||
private val contentType = "application/json".toMediaType() | ||
private val client = OkHttpClient.Builder().addInterceptor(HttpLoggingInterceptor().setLevel(HttpLoggingInterceptor.Level.BODY)).build() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This interceptor
logs for any build type - it shouldn't log in release
build
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
#out-of-pr
ApiService
- there are few things we can improve here :)
- Strings (
"application/json", "https://itunes.apple.com/"
) could be extracted to consts ApiService
could be anobject
- there's no point to create instances of this class other than obtainingItunesService
- Properties like
contentType
,client
,json
are only required to initializeservice
property.
I'd suggest to wrap it into methods and delegate service creation, e.g.:
val service: ItunesService = createItunesService()
private fun createItunesService() = {
val httpClient = getHttpClient()
val retrofit = getRetrofit(httpClient)
return retrofit.create(ItunesService::class.java)
}
OR
We should consider using DI framework in order to provide such dependencies to consumers :)
Either way we should discuss it and do it in a separate task.
var selectedSong: Song? by remember { mutableStateOf(null) } | ||
if (!detailsClicked) { | ||
Column(Modifier.verticalScroll(rememberScrollState())) { | ||
songs.forEach { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm assuming songs
can contain many items - LazyColumn
will be a better component than Column
(performance)
} else { | ||
Column(modifier = Modifier.fillMaxWidth()) { | ||
selectedSong?.let { | ||
Text("What a great detalis page!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"What a great detalis page!"
should be moved to string resources
} | ||
} | ||
Button(onClick = { detailsClicked = false }) { Text("Back") } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Back"
should be moved to string resources
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest to extract parts of the layout to separate functions, to provide more readable structure.
E.g.:
fun SongListScreen(){
if(!detailsClicked){
SongList()
} else {
SongDetails()
}
}
fun SongItem(){
}
@@ -2,5 +2,6 @@ package com.tooploox.androidrecruitmenttask | |||
|
|||
data class Song( | |||
val title: String, | |||
val artist: String | |||
val artist: String, | |||
val releaseYear: Int, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it have to be Int
?
I will add a summary here and some information about pr itself: PR:
Summary:
|
Oh, two more things popped up:
|
Please review this PR at your your leisure. We expect this review to take under 30 minutes, but feel free to take as much or as little time as you want.
Focus on all the areas of code quality you feel important, treat it as a code a colleague in your project pushed to a repo you contribute to.