Skip to content

Commit c961c0f

Browse files
committed
feat: Add dependency injection and application class
This commit introduces Koin for dependency injection and sets up an application class. Changes: - Added `TechExactlyApplication` class to initialize Koin. - Declared the `TechExactlyApplication` in the `AndroidManifest.xml`. - Created `AppModule` to define dependencies, including Retrofit, the User API, and the User repository. - Added the Koin dependency. - `AppModule` created with the following: - `provideRetrofit`: for providing Retrofit instance - `provideUserApi`: for providing UserApi instance - `UserRepository`: for providing repository instance
1 parent 0a65c48 commit c961c0f

3 files changed

Lines changed: 29 additions & 0 deletions

File tree

app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<uses-permission android:name="android.permission.INTERNET" />
66

77
<application
8+
android:name=".TechExactlyApplication"
89
android:allowBackup="true"
910
android:dataExtractionRules="@xml/data_extraction_rules"
1011
android:fullBackupContent="@xml/backup_rules"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.example.techexactly
2+
3+
import android.app.Application
4+
import com.example.techexactly.di.appModule
5+
import org.koin.android.ext.koin.androidContext
6+
import org.koin.core.context.startKoin
7+
8+
class TechExactlyApplication : Application() {
9+
override fun onCreate() {
10+
super.onCreate()
11+
startKoin {
12+
androidContext(this@TechExactlyApplication)
13+
modules(appModule)
14+
}
15+
}
16+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.example.techexactly.di
2+
3+
import com.example.techexactly.model.network.provideRetrofit
4+
import com.example.techexactly.model.network.provideUserApi
5+
import com.example.techexactly.model.repository.UserRepository
6+
import org.koin.dsl.module
7+
8+
val appModule = module {
9+
single { provideRetrofit() }
10+
single { provideUserApi(get()) }
11+
single { UserRepository(get()) }
12+
}

0 commit comments

Comments
 (0)