2024-09-01から1ヶ月間の記事一覧

Dagger - Put Component in Application

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Usually we define the dagger component in custom application class, which will init before any activity. 1. Create Custom Application Class class SmartPhoneApplication: Appl…

Dagger - Module with Parameter

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Please read this article first. If the MemoryCardModule has a parameter memorySize, @Module class MemoryCardModule(private val memorySize: Int) { @Provides fun providesMemor…

Dagger Field Injection

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. In this article we introduced created an abstract function getSmartPhone() and call it to get SmartPhone instance. We can also inject it into another class. This article I'l…

Dagger Binds

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. Please read last article before reading this one. Assuming class SmartPhone has another dependency Battery, and Battery is an interface, NickelCadmiumBattery is its implemen…

Dagger Module and Provides

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. In last article we mentioned we need to add @Inject before dependency class's constructor. However some classes might came from 3rd party library, then we cannot modify them…

Dagger Basic Usage

This is my note for Udemy lesson: Advanced Android Bootcamp 2024. 1. Import Dagger Please check this note 2. Change Class's Constructor Before: class SmartPhone(...) { ... } After: class SmartPhone @Inject constructor(...) { ... } 3. Creat…