-
Notifications
You must be signed in to change notification settings - Fork 0
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 #52 from stslex/feature/mvi_dagger
feature/mvi dagger
- Loading branch information
Showing
183 changed files
with
3,457 additions
and
1,259 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
50 changes: 16 additions & 34 deletions
50
app/src/main/java/st/slex/csplashscreen/SplashApplication.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,43 +1,25 @@ | ||
package st.slex.csplashscreen | ||
|
||
import android.app.Application | ||
import st.slex.csplashscreen.core.collection.di.ModuleCoreCollection.moduleCoreCollection | ||
import st.slex.csplashscreen.core.favourite.di.ModuleCoreFavourite.moduleCoreFavourite | ||
import st.slex.csplashscreen.core.network.di.ModuleCoreNetwork.moduleCoreNetwork | ||
import st.slex.csplashscreen.core.photos.di.ModuleCorePhotos.moduleCorePhotos | ||
import st.slex.csplashscreen.feature.collection.di.singleCollectionModule | ||
import st.slex.csplashscreen.feature.favourite.di.moduleFeatureFavourite | ||
import st.slex.csplashscreen.feature.feature_photo_detail.di.moduleFeaturePhoto | ||
import st.slex.csplashscreen.feature.home.di.moduleFeatureHome | ||
import st.slex.csplashscreen.feature.search.di.moduleFeatureSearchPhotos | ||
import st.slex.csplashscreen.feature.user.di.moduleFeatureUser | ||
import org.koin.android.ext.koin.androidContext | ||
import org.koin.android.ext.koin.androidLogger | ||
import org.koin.core.context.startKoin | ||
import st.slex.csplashscreen.core.core.AppApi | ||
import st.slex.csplashscreen.core.core.ApplicationApiProvider | ||
import st.slex.csplashscreen.di.app.AppComponent | ||
import st.slex.csplashscreen.di.app.DaggerAppComponent | ||
|
||
class SplashApplication : Application() { | ||
class SplashApplication : Application(), ApplicationApiProvider { | ||
|
||
override fun onCreate() { | ||
setUpKoin() | ||
super.onCreate() | ||
private val appComponent: AppComponent by lazy { | ||
DaggerAppComponent | ||
.builder() | ||
.context(this) | ||
.build() | ||
} | ||
|
||
private fun setUpKoin() { | ||
startKoin { | ||
androidLogger() | ||
androidContext(this@SplashApplication) | ||
modules( | ||
singleCollectionModule, | ||
moduleCoreCollection, | ||
moduleCorePhotos, | ||
moduleCoreNetwork, | ||
moduleFeaturePhoto, | ||
moduleFeatureSearchPhotos, | ||
moduleFeatureUser, | ||
moduleFeatureHome, | ||
moduleCoreFavourite, | ||
moduleFeatureFavourite | ||
) | ||
} | ||
override val appApi: AppApi | ||
get() = appComponent | ||
|
||
override fun onCreate() { | ||
appComponent.inject(this) | ||
super.onCreate() | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
app/src/main/java/st/slex/csplashscreen/di/app/AppComponent.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,24 @@ | ||
package st.slex.csplashscreen.di.app | ||
|
||
import android.content.Context | ||
import dagger.BindsInstance | ||
import dagger.Component | ||
import st.slex.csplashscreen.SplashApplication | ||
import st.slex.csplashscreen.core.core.AppApi | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
@Component | ||
interface AppComponent : AppApi { | ||
|
||
@Component.Builder | ||
interface Builder { | ||
|
||
@BindsInstance | ||
fun context(context: Context): Builder | ||
|
||
fun build(): AppComponent | ||
} | ||
|
||
fun inject(application: SplashApplication) | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/st/slex/csplashscreen/di/main/MainComponent.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,33 @@ | ||
package st.slex.csplashscreen.di.main | ||
|
||
import androidx.lifecycle.ViewModelProvider | ||
import dagger.Component | ||
import st.slex.csplashscreen.core.core.AppApi | ||
import st.slex.csplashscreen.core.ui.di.NavigationApi | ||
|
||
@Component( | ||
dependencies = [MainDependencies::class], | ||
modules = [MainModule::class] | ||
) | ||
interface MainComponent { | ||
|
||
@Component.Factory | ||
interface Factory { | ||
fun create(dependencies: MainDependencies): MainComponent | ||
} | ||
|
||
@Component(dependencies = [AppApi::class, NavigationApi::class]) | ||
interface MainDependenciesComponent : MainDependencies { | ||
|
||
@Component.Factory | ||
interface Factory { | ||
fun create( | ||
appApi: AppApi, | ||
navigationApi: NavigationApi | ||
): MainDependenciesComponent | ||
} | ||
} | ||
|
||
val viewModelFactory: ViewModelProvider.Factory | ||
} | ||
|
38 changes: 38 additions & 0 deletions
38
app/src/main/java/st/slex/csplashscreen/di/main/MainComponentBuilder.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,38 @@ | ||
package st.slex.csplashscreen.di.main | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.ui.platform.LocalContext | ||
import st.slex.csplashscreen.core.core.AppApi | ||
import st.slex.csplashscreen.core.core.appApi | ||
import st.slex.csplashscreen.core.ui.base.daggerViewModel | ||
import st.slex.csplashscreen.core.ui.di.NavigationApi | ||
import st.slex.csplashscreen.ui.InitialAppViewModel | ||
|
||
object MainComponentBuilder { | ||
|
||
fun build( | ||
appApi: AppApi, | ||
navigationApi: NavigationApi | ||
): MainComponent = DaggerMainComponent | ||
.factory() | ||
.create( | ||
DaggerMainComponent_MainDependenciesComponent.factory() | ||
.create( | ||
appApi = appApi, | ||
navigationApi = navigationApi | ||
) | ||
) | ||
} | ||
|
||
@Composable | ||
fun setupMainComponent(navigationApi: NavigationApi): InitialAppViewModel { | ||
val context = LocalContext.current | ||
return daggerViewModel { | ||
MainComponentBuilder | ||
.build( | ||
appApi = context.appApi, | ||
navigationApi = navigationApi | ||
) | ||
.viewModelFactory | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
app/src/main/java/st/slex/csplashscreen/di/main/MainDependencies.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,8 @@ | ||
package st.slex.csplashscreen.di.main | ||
|
||
import st.slex.csplashscreen.core.ui.di.Navigator | ||
|
||
interface MainDependencies { | ||
|
||
val navigator: Navigator | ||
} |
22 changes: 22 additions & 0 deletions
22
app/src/main/java/st/slex/csplashscreen/di/main/MainModule.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 st.slex.csplashscreen.di.main | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.ViewModelProvider | ||
import com.stslex93.notes.core.ui.base.ViewModelFactory | ||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.multibindings.IntoMap | ||
import st.slex.csplashscreen.core.ui.di.ViewModelKey | ||
import st.slex.csplashscreen.ui.InitialAppViewModel | ||
|
||
@Module | ||
interface MainModule { | ||
|
||
@Binds | ||
@IntoMap | ||
@ViewModelKey(InitialAppViewModel::class) | ||
fun bindsViewModel(impl: InitialAppViewModel): ViewModel | ||
|
||
@Binds | ||
fun bindsFactory(impl: ViewModelFactory): ViewModelProvider.Factory | ||
} |
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
2 changes: 1 addition & 1 deletion
2
...splashscreen/navigation/NavigationHost.kt → ...ashscreen/ui/components/NavigationHost.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
53 changes: 0 additions & 53 deletions
53
app/src/test/java/st/slex/csplashscreen/DiKoinModuleTest.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.