Last active
June 15, 2019 18:02
-
-
Save berteodosio/59aa43d7dfae6865eade72dd6fa9dc5c to your computer and use it in GitHub Desktop.
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
private class BBInitializer { | |
var context: Context? = null | |
@RawRes | |
var jsonResource: Int? = null | |
var remoteFileUrl: String? = null | |
internal var logInitializer = LogInitializer() | |
fun log(initializeAction: LogInitializer.() -> Unit) { | |
logInitializer.initializeAction() | |
} | |
class LogInitializer { | |
var level: LogLevel = LogLevel.ERROR | |
var ignoreThrowable: Boolean = false | |
} | |
} | |
private fun blockBuilder(initializeAction: BBInitializer.() -> Unit) { | |
val blockBuilderInitializer = BBInitializer() | |
blockBuilderInitializer.initializeAction() | |
val jsonResource = blockBuilderInitializer.jsonResource | |
?: throw NullPointerException("jsonResource must be set") | |
val remoteFileUrl = blockBuilderInitializer.remoteFileUrl | |
?: throw NullPointerException("remoteFileUrl must be set") | |
val context = blockBuilderInitializer.context | |
?: throw NullPointerException("context must be set") | |
val logLevel = blockBuilderInitializer.logInitializer.level | |
val ignoreThrowable = blockBuilderInitializer.logInitializer.ignoreThrowable | |
BlockBuilder | |
.configuration(ConfigurationParameters(jsonResource, remoteFileUrl)) | |
.configureLog(logLevel, ignoreThrowable) | |
.init(context) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment