Skip to content

Instantly share code, notes, and snippets.

@aartikov
Created February 13, 2018 06:46
Show Gist options
  • Save aartikov/886c427d529ba7f22cabbbdcaa967521 to your computer and use it in GitHub Desktop.
Save aartikov/886c427d529ba7f22cabbbdcaa967521 to your computer and use it in GitHub Desktop.
Dagger 2 + Reamp
package ru.eastbanctech.daggertest.base
import android.os.Bundle
import android.support.v4.app.Fragment
import dagger.android.AndroidInjection
import dagger.android.AndroidInjector
import dagger.android.DispatchingAndroidInjector
import dagger.android.support.HasSupportFragmentInjector
import etr.android.reamp.mvp.ReampAppCompatActivity
import etr.android.reamp.mvp.ReampPresenter
import etr.android.reamp.mvp.ReampStateModel
import javax.inject.Inject
import javax.inject.Provider
abstract class BaseActivity<P : ReampPresenter<SM>, SM : ReampStateModel> : ReampAppCompatActivity<P, SM>(), HasSupportFragmentInjector {
@Inject
lateinit var fragmentInjector: DispatchingAndroidInjector<Fragment>
@Inject
lateinit var presenterProvider: Provider<P>
@Inject
lateinit var stateModelProvider: Provider<SM>
override fun onCreate(savedInstanceState: Bundle?) {
AndroidInjection.inject(this)
super.onCreate(savedInstanceState)
}
final override fun supportFragmentInjector(): AndroidInjector<Fragment> = fragmentInjector
final override fun onCreatePresenter(): P = presenterProvider.get()
final override fun onCreateStateModel(): SM = stateModelProvider.get()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment