-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #100 from lucasnlm/migrate-to-hilt
Migrate to hilt
- Loading branch information
Showing
41 changed files
with
251 additions
and
580 deletions.
There are no files selected for viewing
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
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
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
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
36 changes: 8 additions & 28 deletions
36
app/src/main/java/dev/lucasnlm/antimine/MainApplication.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,21 @@ | ||
package dev.lucasnlm.antimine | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import androidx.multidex.MultiDex | ||
import dagger.android.AndroidInjector | ||
import dagger.android.support.DaggerApplication | ||
import dev.lucasnlm.antimine.common.level.di.LevelModule | ||
import androidx.multidex.MultiDexApplication | ||
import dagger.hilt.android.HiltAndroidApp | ||
import dev.lucasnlm.antimine.core.analytics.AnalyticsManager | ||
import dev.lucasnlm.antimine.core.analytics.models.Analytics | ||
import dev.lucasnlm.antimine.di.AppModule | ||
import dev.lucasnlm.antimine.di.DaggerAppComponent | ||
import javax.inject.Inject | ||
|
||
open class MainApplication : DaggerApplication() { | ||
|
||
@HiltAndroidApp | ||
open class MainApplication : MultiDexApplication() { | ||
@Inject | ||
lateinit var analyticsManager: AnalyticsManager | ||
|
||
protected open fun appModule(application: Application) = AppModule(application) | ||
|
||
protected open fun levelModule(application: Application) = LevelModule(application) | ||
|
||
override fun applicationInjector(): AndroidInjector<out DaggerApplication> = | ||
DaggerAppComponent.builder() | ||
.application(this) | ||
.appModule(appModule(this)) | ||
.levelModule(levelModule(this)) | ||
.build() | ||
|
||
override fun attachBaseContext(base: Context?) { | ||
super.attachBaseContext(base) | ||
MultiDex.install(this) | ||
} | ||
|
||
override fun onCreate() { | ||
super.onCreate() | ||
analyticsManager.setup(applicationContext, mapOf()) | ||
analyticsManager.sentEvent(Analytics.Open()) | ||
analyticsManager.apply { | ||
setup(applicationContext, mapOf()) | ||
sentEvent(Analytics.Open()) | ||
} | ||
} | ||
} |
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
28 changes: 0 additions & 28 deletions
28
app/src/main/java/dev/lucasnlm/antimine/di/ActivityModule.kt
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
app/src/main/java/dev/lucasnlm/antimine/di/AppComponent.kt
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
package dev.lucasnlm.antimine.di | ||
|
||
import android.app.Application | ||
import android.content.Context | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.android.components.ApplicationComponent | ||
import dagger.hilt.android.qualifiers.ApplicationContext | ||
import dev.lucasnlm.antimine.instant.InstantAppManager | ||
|
||
@Module | ||
class AppModule( | ||
private val application: Application | ||
) { | ||
@InstallIn(ApplicationComponent::class) | ||
class AppModule { | ||
@Provides | ||
fun provideContext(): Context = application.applicationContext | ||
|
||
@Provides | ||
fun provideInstantAppManager(): InstantAppManager = InstantAppManager(application.applicationContext) | ||
fun provideInstantAppManager( | ||
@ApplicationContext context: Context | ||
): InstantAppManager = InstantAppManager(context) | ||
} |
23 changes: 0 additions & 23 deletions
23
app/src/main/java/dev/lucasnlm/antimine/di/FragmentModule.kt
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.