ChangeServerModule.kt 1.09 KB
Newer Older
1 2
package chat.rocket.android.server.di

3
import androidx.lifecycle.LifecycleOwner
4 5
import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.dagger.scope.PerActivity
6
import chat.rocket.android.dagger.scope.PerFragment
7 8 9 10 11 12 13 14 15
import chat.rocket.android.server.presentation.ChangeServerNavigator
import chat.rocket.android.server.presentation.ChangeServerView
import chat.rocket.android.server.ui.ChangeServerActivity
import dagger.Module
import dagger.Provides
import kotlinx.coroutines.experimental.Job

@Module
class ChangeServerModule {
16 17 18 19 20

    @Provides
    @PerActivity
    fun provideJob() = Job()

21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
    @Provides
    @PerActivity
    fun provideChangeServerNavigator(activity: ChangeServerActivity) = ChangeServerNavigator(activity)

    @Provides
    @PerActivity
    fun ChangeServerView(activity: ChangeServerActivity): ChangeServerView {
        return activity
    }

    @Provides
    fun provideLifecycleOwner(activity: ChangeServerActivity): LifecycleOwner = activity

    @Provides
    fun provideCancelStrategy(owner: LifecycleOwner, jobs: Job): CancelStrategy = CancelStrategy(owner, jobs)
}