This file contains hidden or 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
| repositories { | |
| // your repositories | |
| jcenter() | |
| } | |
| kotlin { | |
| jvm("android") | |
| ios() | |
| sourceSets { |
This file contains hidden or 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
| // Auth API | |
| interface AuthApi { | |
| suspend fun authenticate(pid: Int, deviceId: String): Token | |
| } | |
| class AuthApiImpl : ClientApi(), AuthApi { | |
| override suspend fun authenticate(pid: Int, deviceId: String)= | |
| client.get<Token> { / * implementation */ } | |
| } | |
| // Token repository | |
| interface TokenRepository { |
This file contains hidden or 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
| // Login MVP definition | |
| class Login { | |
| interface Presenter { | |
| fun checkAuthentication() | |
| fun authenticate(secret: String) | |
| } | |
| interface View : BaseView { | |
| fun onLoginSuccess() | |
| } |
This file contains hidden or 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
| /** | |
| * Participant API | |
| */ | |
| interface ParticipantApi { | |
| suspend fun getAll(): List<Participant> | |
| suspend fun create(participant: Participant) : Participant | |
| suspend fun update(participant: Participant) : Participant | |
| suspend fun delete(participant: Participant) : Boolean | |
| suspend fun postPhoto(participant: Participant, input: Input, extension: String) : String | |
| } |
This file contains hidden or 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
| val loginModule = DI.Module("login") { | |
| bind<TokenRepository>() with singleton { TokenRepositoryImpl(instance()) } | |
| bind("isLoggedIn") from provider { instance<TokenRepository>().isLoggedIn() } | |
| bind<AuthApi>() with singleton { AuthApiImpl() } | |
| bind<LoginPresenter>() with provider { LoginPresenterImpl(di) } | |
| } |
This file contains hidden or 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
| val participantModule = DI.Module("participant") { | |
| bind<ParticipantRepository>() with singleton { ParticipantRepositoryImpl(instance()) } | |
| bind<ParticipantApi>() with singleton { ParticipantApiImpl(instance()) } | |
| bind<ParticipantCreation.Presenter>() with provider { ParticipantCreationPresenterImpl(di) } | |
| bind<VoteCreation.Presenter>() with provider { VoteCreationPresenterImpl(di) } | |
| bind<PhotoUpload.Presenter>() with provider { PhotoUploadPresenterImpl(di) } | |
| bind<ParticipantList.Presenter>() with provider { ParticipantListPresenterImpl(di) } |
This file contains hidden or 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
| @ThreadLocal | |
| object CommonInjector { | |
| val kodeinContainer = DI.lazy { | |
| importAll(databaseModule, loginModule, participantModule) | |
| } | |
| // Direct access to the presenters | |
| fun participantListPresenter() = kodeinContainer.direct.instance<ParticipantList.Presenter>() | |
| fun participantCreationPresenter() = kodeinContainer.direct.instance<ParticipantCreation.Presenter>() | |
| fun voteCreationPresenter() = kodeinContainer.direct.instance<VoteCreation.Presenter>() |
This file contains hidden or 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
| val kodeinContainer = DI.lazy { | |
| importAll(databaseModule, loginModule, participantModule) | |
| } |
This file contains hidden or 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
| kotlin { | |
| // ... | |
| sourceSets { | |
| // ... | |
| val commonTest by getting { | |
| dependencies { | |
| implementation(kotlin("test-common")) | |
| implementation(kotlin("test-annotations-common")) | |
| } | |
| } |
This file contains hidden or 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
| kotlin { | |
| // ... | |
| sourceSets { | |
| // ... | |
| val jvmTest by getting { | |
| dependencies { | |
| implementation(kotlin("test")) | |
| implementation(kotlin("test-junit")) | |
| } | |
| } |