Skip to content

Commit

Permalink
Merge pull request #43 from its-me-debk007/moshi
Browse files Browse the repository at this point in the history
migrate from moshi reflection to codegen
  • Loading branch information
its-me-debk007 authored May 26, 2024
2 parents 55923cf + fb4ef0f commit 3204f6e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ dependencies {
debugImplementation(libs.ui.test.manifest)
implementation(libs.retrofit)
implementation(libs.moshi.converter)
ksp(libs.moshi.kotlin.codegen)
implementation(libs.glide)
implementation(libs.coroutines.android)
implementation(libs.coroutines.core)
Expand All @@ -98,5 +99,4 @@ dependencies {
implementation(libs.navigation.compose)
debugImplementation(libs.chucker.debug)
releaseImplementation(libs.chucker.release)
implementation(libs.moshi.kotlin)
}
20 changes: 6 additions & 14 deletions app/src/main/java/com/debk007/template/di/NetworkModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import com.debk007.template.BuildConfig
import com.debk007.template.network.ApiService
import com.debk007.template.repository.Repository
import com.debk007.template.repository.RepositoryImpl
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
Expand All @@ -30,18 +28,12 @@ object NetworkModule {

@Provides
@Singleton
fun providesRetrofit(okHttpClient: OkHttpClient): ApiService {
val moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()

return Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.client(okHttpClient)
.build()
.create(ApiService::class.java)
}
fun providesRetrofit(okHttpClient: OkHttpClient): ApiService = Retrofit.Builder()
.baseUrl(BuildConfig.BASE_URL)
.addConverterFactory(MoshiConverterFactory.create())
.client(okHttpClient)
.build()
.create(ApiService::class.java)

@Provides
@Singleton
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ espresso-core = "3.5.1"
lifecycle-runtime-ktx = "2.8.0"
activity-compose = "1.9.0"
compose-bom = "2024.05.00"
moshi-kotlin = "1.14.0"
moshi-kotlin-codegen = "1.15.1"
retrofit = "2.11.0"
coroutines = "1.8.0"
hilt-navigation-compose = "1.2.0"
Expand All @@ -26,7 +26,7 @@ espresso-core = { group = "androidx.test.espresso", name = "espresso-core", vers
lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycle-runtime-ktx" }
activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "activity-compose" }
compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "compose-bom" }
moshi-kotlin = { module = "com.squareup.moshi:moshi-kotlin", version.ref = "moshi-kotlin" }
moshi-kotlin-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version.ref = "moshi-kotlin-codegen" }
ui = { group = "androidx.compose.ui", name = "ui" }
ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }
ui-tooling = { group = "androidx.compose.ui", name = "ui-tooling" }
Expand Down

0 comments on commit 3204f6e

Please sign in to comment.