-
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 #190 from LachlanMcKee/use-hilt-in-sample-app
Use hilt in demo app
- Loading branch information
Showing
30 changed files
with
168 additions
and
382 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
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
43 changes: 0 additions & 43 deletions
43
mvicore-demo/mvicore-demo-app/src/main/java/com/badoo/mvicoredemo/di/ScopedComponent.kt
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
...-demo-app/src/main/java/com/badoo/mvicoredemo/di/activityscope/module/ActivityModule.java
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
...re-demo-app/src/main/java/com/badoo/mvicoredemo/di/activityscope/scope/ActivityScope.java
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...vicore-demo-app/src/main/java/com/badoo/mvicoredemo/di/appscope/component/AppComponent.kt
This file was deleted.
Oops, something went wrong.
16 changes: 0 additions & 16 deletions
16
...-demo-app/src/main/java/com/badoo/mvicoredemo/di/appscope/component/AppScopedComponent.kt
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
.../mvicore-demo-app/src/main/java/com/badoo/mvicoredemo/di/appscope/module/AndroidModule.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
11 changes: 0 additions & 11 deletions
11
...demo/mvicore-demo-app/src/main/java/com/badoo/mvicoredemo/di/appscope/scope/AppScope.java
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
...o/mvicore-demo-app/src/main/java/com/badoo/mvicoredemo/di/usersessionscope/UserManager.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,44 @@ | ||
package com.badoo.mvicoredemo.di.usersessionscope; | ||
|
||
import android.app.Application | ||
import com.badoo.mvicoredemo.di.usersessionscope.component.UserComponentEntryPoint | ||
import com.badoo.mvicoredemo.di.usersessionscope.component.UserSessionComponent | ||
import dagger.hilt.EntryPoints | ||
import io.reactivex.disposables.CompositeDisposable | ||
import javax.inject.Inject | ||
import javax.inject.Provider | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class UserManager @Inject constructor( | ||
private val userSessionComponentBuilderProvider: Provider<UserSessionComponent.Builder> | ||
) { | ||
var userComponent: UserSessionComponent? = null | ||
private set | ||
|
||
fun userLoggedIn() { | ||
userComponent = userSessionComponentBuilderProvider.get().build() | ||
} | ||
|
||
fun logout() { | ||
userComponent?.apply { | ||
val userPartsEntryPoint = UserComponentEntryPoint.get(this) | ||
CompositeDisposable() | ||
.apply { | ||
addAll( | ||
userPartsEntryPoint.feature1(), | ||
userPartsEntryPoint.feature2(), | ||
) | ||
} | ||
.dispose() | ||
} | ||
userComponent = null | ||
} | ||
|
||
companion object { | ||
fun getUserManager(application: Application): UserManager = | ||
EntryPoints | ||
.get(application, UserManagerEntryPoint::class.java) | ||
.userManager() | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...demo-app/src/main/java/com/badoo/mvicoredemo/di/usersessionscope/UserManagerEntryPoint.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,11 @@ | ||
package com.badoo.mvicoredemo.di.usersessionscope | ||
|
||
import dagger.hilt.EntryPoint | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
|
||
@InstallIn(SingletonComponent::class) | ||
@EntryPoint | ||
interface UserManagerEntryPoint { | ||
fun userManager(): UserManager | ||
} |
Oops, something went wrong.