-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace gson converter with kotlinx serialization
- Loading branch information
1 parent
0aa9871
commit c6f48c4
Showing
6 changed files
with
42 additions
and
48 deletions.
There are no files selected for viewing
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
34 changes: 34 additions & 0 deletions
34
network/src/main/kotlin/dev/atick/network/di/retrofit/ConverterModule.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,34 @@ | ||
package dev.atick.network.di.retrofit | ||
|
||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import kotlinx.serialization.json.Json | ||
import okhttp3.MediaType.Companion.toMediaType | ||
import retrofit2.Converter | ||
import retrofit2.converter.kotlinx.serialization.asConverterFactory | ||
import javax.inject.Singleton | ||
|
||
/** | ||
* Module for providing [Converter.Factory]. | ||
*/ | ||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
object ConverterModule { | ||
/** | ||
* Provides kotlinx.serialization [Converter.Factory]. | ||
* | ||
* @return [Converter.Factory]. | ||
*/ | ||
@Provides | ||
@Singleton | ||
fun provideConverter(): Converter.Factory { | ||
val json = Json { | ||
ignoreUnknownKeys = true | ||
} | ||
return json.asConverterFactory( | ||
"application/json; charset=UTF8".toMediaType(), | ||
) | ||
} | ||
} |
43 changes: 0 additions & 43 deletions
43
network/src/main/kotlin/dev/atick/network/di/retrofit/GsonConverterModule.kt
This file was deleted.
Oops, something went wrong.
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