-
Notifications
You must be signed in to change notification settings - Fork 18
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 #4 from PhilippeBoisney/dev
Migrate to Koin
- Loading branch information
Showing
18 changed files
with
89 additions
and
204 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
12 changes: 10 additions & 2 deletions
12
android/app/src/androidTest/java/io/nobullshit/nobullshit/base/TIBaseApplication.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,10 +1,18 @@ | ||
package io.nobullshit.nobullshit.base | ||
|
||
import android.app.Application | ||
import org.koin.android.ext.android.startKoin | ||
import org.koin.dsl.module.Module | ||
|
||
/** | ||
* We use a separate App for tests to prevent initializing dependency injection. | ||
* We use a separate [Application] for tests to prevent initializing release modules. | ||
* On the contrary, we will provide inside our tests custom [Module]. | ||
* | ||
* See [io.nobullshit.nobullshit.TIRunner]. | ||
*/ | ||
class TIBaseApplication : Application() | ||
class TIBaseApplication : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
startKoin(this, emptyList()) | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...oid/app/src/androidTest/java/io/nobullshit/nobullshit/di/remote_datasource_test_module.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package io.nobullshit.nobullshit.di | ||
|
||
import com.google.firebase.firestore.FirebaseFirestore | ||
import com.google.firebase.firestore.Query | ||
import io.mockk.mockk | ||
import io.nobullshit.nobullshit.db.dao.JobDao | ||
import io.nobullshit.nobullshit.model.Job | ||
import io.nobullshit.nobullshit.util.mockQuery | ||
import org.koin.dsl.module.module | ||
|
||
/** | ||
* Remote [FirebaseFirestore] datasource only used for tests | ||
* @param listApprovedJobs: Mocked [Query] used to return a custom list of jobs. | ||
*/ | ||
fun remoteDataSourceTestModule(listApprovedJobs: Query) = module { | ||
factory { mockk<FirebaseFirestore>(relaxed = true) } | ||
single { | ||
object : JobDao(get()) { | ||
override fun listApprovedJobs() = listApprovedJobs | ||
} as JobDao | ||
} | ||
} |
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
16 changes: 4 additions & 12 deletions
16
android/app/src/main/java/io/nobullshit/nobullshit/base/BaseApplication.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,20 +1,12 @@ | ||
package io.nobullshit.nobullshit.base | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import dagger.android.DispatchingAndroidInjector | ||
import dagger.android.HasActivityInjector | ||
import io.nobullshit.nobullshit.di.AppInjector | ||
import javax.inject.Inject | ||
|
||
class BaseApplication: Application(), HasActivityInjector { | ||
@Inject | ||
lateinit var dispatchingAndroidInjector: DispatchingAndroidInjector<Activity> | ||
import io.nobullshit.nobullshit.di.appComponents | ||
import org.koin.android.ext.android.startKoin | ||
|
||
class BaseApplication: Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
AppInjector.init(this) | ||
startKoin(this, appComponents) | ||
} | ||
|
||
override fun activityInjector() = dispatchingAndroidInjector | ||
} |
28 changes: 0 additions & 28 deletions
28
android/app/src/main/java/io/nobullshit/nobullshit/di/AppComponent.kt
This file was deleted.
Oops, something went wrong.
49 changes: 0 additions & 49 deletions
49
android/app/src/main/java/io/nobullshit/nobullshit/di/AppInjector.kt
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
android/app/src/main/java/io/nobullshit/nobullshit/di/DataModule.kt
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
android/app/src/main/java/io/nobullshit/nobullshit/di/FragmentBuildersModule.kt
This file was deleted.
Oops, something went wrong.
6 changes: 0 additions & 6 deletions
6
android/app/src/main/java/io/nobullshit/nobullshit/di/Injectable.kt
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
android/app/src/main/java/io/nobullshit/nobullshit/di/MainActivityModule.kt
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
android/app/src/main/java/io/nobullshit/nobullshit/di/app_component.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package io.nobullshit.nobullshit.di | ||
|
||
import org.koin.dsl.module.Module | ||
import org.koin.dsl.module.module | ||
|
||
/** | ||
* App Components | ||
*/ | ||
val appComponents: List<Module> = listOf(remoteDataSourceModule) |
Oops, something went wrong.