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
plugins { | |
id("com.android.library") | |
id("com.quickbirdstudios.bluesquare") | |
} | |
dependencies { | |
implementation(kotlin("stdlib-jdk8")) | |
testImplementation("junit:junit:4.12") | |
andriodTestImplementation("com.android.support.test:runner:1.0.2") | |
androidTestImplementation("com.android.support.test.espresso:espresso-core:3.0.2") |
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
// BluesquarePlugin.kt | |
open class BluesquarePlugin : Plugin<Project> { | |
override fun apply(project: Project) { | |
project.configureAndroid() | |
} | |
} | |
// Android.kt | |
internal fun Project.configureAndroid() = this.extensions.getByType<AndroidBaseExtension>().run { |
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
android { | |
compileSdkVersion(28) | |
// ... | |
} |
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
plugins { | |
// ... | |
id("com.android.library") | |
id("com.quickbirdstudios.bluesquare") | |
} |
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
implementation-class=com.quickbirdstudios.bluesqure.BluesquarePlugin |
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
open class BluesquarePlugin : Plugin<Project> { | |
override fun apply(project: Project) { | |
} | |
} |
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
plugins { | |
`kotlin-dsl` | |
} | |
repositories { | |
mavenCentral() | |
google() | |
jcenter() | |
} |
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
let basketViewController = basketContainer.resolve(BasketViewController.self) |
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
let basketContainer = Container() | |
.register(Bundle.self, instance: Bundle.main) | |
.register(Repository<Article>.self) { _ in DatabaseRepository() } | |
.register(BasketService.self) { resolver in | |
let repository = resolver.resolve(Repository<Article>.self) | |
return BasketService(repository: repository) | |
} | |
.register(BasketViewController.self) { resolver in | |
let basketViewController = BasketViewController() | |
basketViewController.basketService = resolver.resolve(BasketService.self) |
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
// MARK: Resolver | |
func resolve<ServiceType>(_ type: ServiceType.Type) -> ServiceType { | |
guard let factory = factories.first(where: { $0.supports(type) }) else { | |
fatalError("No suitable factory found") | |
} | |
return factory.resolve(self) | |
} |