Skip to content

Commit

Permalink
[FEATURE] #1 Di Module 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
eshc123 committed Sep 14, 2022
1 parent ccafd6e commit 77d67b4
Show file tree
Hide file tree
Showing 5 changed files with 170 additions and 5 deletions.
14 changes: 12 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@

<activity
android:name="com.eshc.feature.login.LoginActivity"
android:exported="true">
android:exported="true"
android:launchMode="singleTask">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />

<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data
android:host="github-login"
android:scheme="repo-app" />
</intent-filter>
</activity>
</application>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,39 @@
package com.eshc.mygithubrepoapp.di

class DataSourceModule {
import com.eshc.data.source.*
import com.eshc.data.source.remote.*
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
abstract class DataSourceModule {

@Binds
abstract fun bindAuthDataSource(
authDataSource : AuthDataSourceImpl
) : AuthDataSource

@Binds
abstract fun bindIssueDataSource(
issueDataSource : IssueDataSourceImpl
) : IssueDataSource

@Binds
abstract fun bindNotificationDataSource(
notificationDataSource : NotificationDataSourceImpl
) : NotificationDataSource

@Binds
abstract fun bindRepoDataSource(
repoDataSource: RepoDataSourceImpl
) : RepoDataSource

@Binds
abstract fun bindUserDataSource(
userDataSource: UserDataSourceImpl
) : UserDataSource

}
66 changes: 65 additions & 1 deletion app/src/main/java/com/eshc/mygithubrepoapp/di/NetworkModule.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,68 @@
package com.eshc.mygithubrepoapp.di

class NetworkModule {
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import okhttp3.OkHttpClient
import retrofit2.CallAdapter
import retrofit2.Converter
import retrofit2.Retrofit
import retrofit2.adapter.rxjava3.RxJava3CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import java.util.concurrent.TimeUnit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object NetworkModule {

@Provides
@Singleton
fun provideAuthRetrofit(
okHttpClient: OkHttpClient,
converter : Converter.Factory
) : Retrofit {
return Retrofit.Builder()
.client(okHttpClient)
.baseUrl("https://github.com")
.addConverterFactory(converter)
.build()
}

@Provides
@Singleton
fun provideGithubRetrofit(
okHttpClient: OkHttpClient,
converter : Converter.Factory,
callAdapter: CallAdapter.Factory
) : Retrofit {
return Retrofit.Builder()
.client(okHttpClient)
.baseUrl("https://api.github.com")
.addConverterFactory(converter)
.addCallAdapterFactory(callAdapter)
.build()
}

@Provides
@Singleton
fun provideConvertFactory(): Converter.Factory {
return GsonConverterFactory.create()
}

@Provides
@Singleton
fun provideCallAdapterFactory() : CallAdapter.Factory {
return RxJava3CallAdapterFactory.create()
}

@Provides
@Singleton
fun provideHttpClient() : OkHttpClient {
return OkHttpClient.Builder()
.connectTimeout(3,TimeUnit.SECONDS)
.build()
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,38 @@
package com.eshc.mygithubrepoapp.di

class RepositoryModule {
import com.eshc.data.repository.*
import com.eshc.domain.repository.*
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent

@Module
@InstallIn(SingletonComponent::class)
abstract class RepositoryModule {

@Binds
abstract fun bindAuthRepository(
authRepository : AuthRepositoryImpl
) : AuthRepository

@Binds
abstract fun bindIssueRepository(
issueRepository: IssueRepositoryImpl
) : IssueRepository

@Binds
abstract fun bindNotificationRepository(
notificationRepository: NotificationRepositoryImpl
) : NotificationRepository

@Binds
abstract fun bindRepoRepository(
repoRepository: RepoRepositoryImpl
) : RepoRepository

@Binds
abstract fun bindUserRepository(
userRepository: UserRepositoryImpl
) : UserRepository
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/eshc/mygithubrepoapp/di/ServiceModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.eshc.mygithubrepoapp.di

import com.eshc.data.source.remote.api.AuthService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import retrofit2.Retrofit
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object ServiceModule {

@Provides
@Singleton
fun provideAuthService(
retrofit: Retrofit
) : AuthService {
return retrofit.create(AuthService::class.java)
}
}

0 comments on commit 77d67b4

Please sign in to comment.