Created
December 23, 2023 09:44
-
-
Save chiragthummar/bca4b2f79e9210c30deba041d81fcccc to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import com.md.jetpackcomposemviarchitecture.data.remote.ImageApi | |
import dagger.Module | |
import dagger.Provides | |
import dagger.hilt.InstallIn | |
import dagger.hilt.components.SingletonComponent | |
import okhttp3.OkHttpClient | |
import okhttp3.logging.HttpLoggingInterceptor | |
import retrofit2.Retrofit | |
import retrofit2.converter.gson.GsonConverterFactory | |
import java.util.concurrent.TimeUnit | |
import javax.inject.Singleton | |
@Module | |
@InstallIn(SingletonComponent::class) | |
object AppModule { | |
@Provides | |
@Singleton | |
fun provideInfiniteImageApi(): ImageApi { | |
return Retrofit.Builder() | |
.baseUrl("https://lexica.art/api/v1/") | |
.addConverterFactory(GsonConverterFactory.create()) | |
.client( | |
OkHttpClient.Builder() | |
.connectTimeout(30, TimeUnit.SECONDS) | |
.readTimeout(30, TimeUnit.SECONDS) | |
.writeTimeout(30, TimeUnit.SECONDS) | |
.addInterceptor(HttpLoggingInterceptor().apply { | |
level = HttpLoggingInterceptor.Level.BODY | |
}).build() | |
) | |
.build() | |
.create(ImageApi::class.java) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment