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
class mainActivity { | |
} |
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
dependencies { | |
. | |
. | |
implementation "com.google.dagger:dagger-android:2.16" | |
. | |
} |
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
class myApplication : Application(), HasActivityInjector { | |
@Inject | |
lateinit var activityInjector: DispatchingAndroidInjector<Activity> | |
override fun onCreate() { | |
super.onCreate() | |
} | |
override fun activityInjector(): AndroidInjector<Activity> { |
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
@Component( | |
modules = [ | |
ActivitiesModule::class | |
] | |
) | |
interface AppComponent { | |
fun inject(myApplication: MyApplication) | |
} |
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
@Module | |
abstract class ActivitiesModule { | |
@ContributesAndroidInjector | |
abstract fun contributeMainActivity(): MainActivity | |
} |
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
class MainActivity : AppCompatActivity() { | |
@Inject | |
lateinit var viewModel: MainActivityViewModel | |
override fun onCreate(savedInstanceState: Bundle?) { | |
AndroidInjection.inject(this) | |
super.onCreate(savedInstanceState) | |
setContentView(R.layout.activity_main) |
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
class MainActivityViewModel @Inject constructor() { | |
var someData = "MyString" | |
} |
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
class myApplication : Application(), HasActivityInjector { | |
@Inject | |
lateinit var activityInjector: DispatchingAndroidInjector<Activity> | |
override fun onCreate() { | |
super.onCreate() | |
var appComponent = DaggerAppComponent.create() | |
appComponent.inject(this) | |
} |
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
apply plugin: 'com.android.application' | |
apply plugin: 'kotlin-android' | |
apply plugin: 'kotlin-android-extensions' | |
apply plugin: 'kotlin-kapt' // Kotlin Annotation processing tool | |
android { | |
compileSdkVersion 28 |